Closed mcncl closed 1 year ago
You can just change the variable name!
mutation SSOProviderCreate(
$typ: SSOProviderTypes! # <--
$note: String
) {
ssoProviderCreate(
input: {
type: $typ # <--
note: $note
}
) {
ssoProviderEdge {
node {
id
}
}
}
}
or to $type_
, $ssoType
, etc. -- point is that's something that you set, not something that has to match the schema.
Describe the bug It's not possible to use Go keywords as a variable in a GraphQL query. This means I cannot have a variable
type
, for example in mymutation
.To Reproduce Using the following in my
sso.graphql
file:I am unable to successfully run the
generate
command as I get the following error:If I remove the
type
then I do not receive this error. I believe this is due to a change made in https://github.com/Khan/genqlient/pull/195#issuecomment-1641313276, though I agree with the change, it might be sensible to offer a means of mapping to the name on the GraphQL server rather than forcing folks to not use a plethora of reserved keywords.Obviously, in a
Query
I can use ailasing if need be withproviderType: type
, but that's not possible with aMutation
.Expected behavior I expect that the
generate
command will complete.genqlient version github.com/Khan/genqlient v0.6.0
Additional context I tried the examples mentioned in the PR already and the initial comment on that PR was made as a result of an internal escalation I raised due to this issue questioning what the impact would be on changing our
type
to be a non-Go keyword such asproviderType
, but this seems like more of an oversight with Genqlient as we cannot be the only team using a reserved keyword of some kind in our API.