Skip to content

InputObject field defaults are ignored/overridden #228

Open
@kateile

Description

@kateile

Describe the bug
Hi geeks, Thanks for this amazing lib. I have the following graphql input with default fields

input FormInput {
    hint: String
    inputType: MwappFormInputType = TEXT
    key: String = "form"
    label: String = "Fill form"
    maxLength: Int = 100
    multiSubmission: Boolean = false
    multiline: Boolean = false
    obscure: Boolean = false
}

input SendMessageInput {
    form: FormInput
}

type Mutation {
    sendMessage(connectionId: ID!, input: SendMessageInput!): String!
}

Which I use in golang like

mw.SendMessage(ConnectionId, mwapp.SendMessageInput{
		Message: "Hi, Please tell us your name. \n you can write it below",
		Form: &mwapp.FormInput{
			Key: FormKeyName.String(),
		},
	})

As you can see above I just use one field Key and ignore the rest. So I expect the default graphql fields specified in schema to be used when send request. But they are sent like null too.

To Reproduce
Create mutation whose input have fields with default fields

Expected behavior
Default fields to be respected when. I believe having pointer with omitempty in the generated code will be the solution. But I don't know how to archive this

genqlient version
v0.5.0

Additional context
My genqclient.yaml is

schema: schema.graphql
package: mwapp
operations:
- operations/*.graphql
generated: generated.go
use_struct_references : true
optional: pointer
bindings:
  Timestamp:
    type: time.Time

Any help on fixing this will be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions