apollographql / apollographql/apollo-tooling

[Swift] support defaultValue for input object

Open
#1,257 0 comments 0 reactions 0 assignees View on GitHub
:bird: component - swift 🤖 component - codegen
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

Using apollo `2.11`

Having a GraphQL schema returning a `defaultValue` for an input object does not seem to be supported:
```
{
"kind": "INPUT_OBJECT",
"name": "foo",
"description": null,
"fields": null,
"inputFields": [
{
"name": "fooStatus",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "ENUM",
"name": "FooStatus",
"ofType": null
}
},
"defaultValue": "MY_STATUS"
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
```

Swift generated code:

public struct data: GraphQLMapConvertible {

public var graphQLMap: GraphQLMap

public init( refid: String, fooStatus: FooStatus) {
...
}

Where I would expect:

public struct data: GraphQLMapConvertible {

public var graphQLMap: GraphQLMap

public init( refid: String, fooStatus: FooStatus = FooStatus.myStatus) {
...
}

Contributor guide

Open the contributing guide

Research direction

No source file or test is named. Start by tracing Swift input-object generation from the introspection inputFields/defaultValue data shown in the issue, then verify that the generated initializer includes the enum default and that existing generated-code checks still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.