Generate & scaffold type-safe resolvers based on your GraphQL Schema in TypeScript, Flow & Reason
Deprecation note
graphqlgen has been officially deprecated in favor of the The Guild's project GraphQL Code Generator. Learn more about the collaboration of Prisma and the Guild in this blog post.
Type-safety Resolvers with precise signatures including parent, args and return type
DX Precise resolver types puts your editor intellisense to work
Ecosystem Interop codegen suitable for Yoga 1 or Apollo Server and supports prettier and graphql-import out of the box
Motivation
Programming in type-safe environments can contribute toward great confidence in your code's integrity. graphqlgen aims to leverage the GraphQL type system to make your resolvers completely type-safe. This is important because resolvers are the heart of any graphql service and yet the hardest to statically type due to their dynaminism.
Then you will have access to the cli (gg or graphqlgen):
yarn -s gg --help # npm run gg --help
Usage: graphqlgen or gg
Options:
-i, --init Initialize a graphqlgen.yml file
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
gg depends on the presence of a graphqlgen.yml config located in the directory where gg is invoked. Here is an example:
graphqlgen is still in early stage development where breaking changes and tool design are a fluid matter. Feedback is deeply appreciated. You may feel comfortable giving it a try on production systems since there is no runtime aspect and hence quite safe to do so (save for a few optional default resolvers).
Prior Art
gqlgen is the Golang equivalent of graphqlgen and served as a source of inspiration
graphql-code-generator is a similar tool based on templates support both frontend & backend
请发表评论