Graphql-go: @deprecated directive on `input`

Created on 8 May 2018  路  5Comments  路  Source: graph-gophers/graphql-go

Since https://github.com/graph-gophers/graphql-go/commit/498fe3961c3058c45f5ad90b1212a48adfbba266 we can add @deprecated to types like so:

type User {
  name: String!
  age: int @deprecated(reason: "Use `dob` instead")
  dob: Date!
}

However the @deprecated directive throws an error on input:

input UserInput {
  name: String!
  age: int! = 0 @deprecated(reason: "Use `dob` instead")
  dob: Date!
}
panic: graphql: syntax error: unexpected "@", expecting Ident

Most helpful comment

At the time I started writing gqlgen this package was unmaintained, and I wanted to take it in a very different direction (the whole execution phase & json marshalling is generated out as go code). I can't realistically expect anyone to merge a 5k+ line PR to the core request executor.

I still think a heap of work can be shared, bringing the whole go graphql ecosystem forward, like getting a robust parser & validator out independent of the server.

All 5 comments

Also found that it's not supported on Field Args either, eg:

type User {
  properties(
    limit: int = 20 @deprecated(reason: "limit is no longer supported, always returns all")
  ): [Property!]!
}
panic: graphql: syntax error: unexpected "@", expecting Ident

I've started work in a new parser that should support all of these and a bunch of other new features like schema extensions. It's up to Tony if that lands here, but feel free to have a look.

https://github.com/vektah/gqlparser

Looks interesting @vektah Thanks for sharing.
gqlgen looks good too; just wondering why you created a new project, rather than contributing to this one? Would be nice to have a "de facto" GraphQL Server for Golang... much like Apollo is for Javascript.

At the time I started writing gqlgen this package was unmaintained, and I wanted to take it in a very different direction (the whole execution phase & json marshalling is generated out as go code). I can't realistically expect anyone to merge a 5k+ line PR to the core request executor.

I still think a heap of work can be shared, bringing the whole go graphql ecosystem forward, like getting a robust parser & validator out independent of the server.

This is working its way into the spec https://github.com/facebook/graphql/pull/525

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jakubdal picture jakubdal  路  6Comments

estutzenberger picture estutzenberger  路  4Comments

bsr203 picture bsr203  路  7Comments

JitinGuglani picture JitinGuglani  路  6Comments

0xTanvir picture 0xTanvir  路  5Comments