Skip to content

Default argument for object with no required fields fails to build in Xcode #3249

@tt-pkaminski

Description

@tt-pkaminski

Summary

Example:

I have a type that has no required fields. There is a default argument for the only field

input MyType {
    a: Float = 1.0
}

In my query, I provide a default argument

query myQuery($arg: MyType! = {})

When I run code gen, there are no errors from the script and I get the following output:

struct MyType {
    public init(a: GraphQLNullable<Double>) {
        ...
    }
}

class MyQuery {
    public init(arg: MyType = MyType()) {...}
}

However, because the initializer for MyType does not include either a default argument of 1.0 or nil, the generated code fails to compile

MyQuery.graphql => Missing argument for parameter #1 in call

Version

1.5

Steps to reproduce the behavior

See the above code for an reproducible example

Logs

No response

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions