It seems that the type definitions generated by codegen are targeted for use in client applications - the structures are driven by query definitions, and so only the properties specified in the query are included in the generated data type.
However, what I would like is TypeScript data definitions for server-side processing, specifically the data types returned by my GraphQL resolvers. I already have type definitions for all of my database record formats (authored by hand). However, the database records aren't exactly the same format as the GraphQL schema, and so there's a conversion step. It would be great to be able to have type checking during the conversion from database record type to GraphQL type. For example, if a new field gets added to the schema, the compiler should complain that I'm not populating that field from the corresponding database column.
In the vast majority of cases this means that the GraphQL type definitions would include all of the fields in the schema. Now, I could do this by creating "fake" queries that request every field. But this violates DRY, and it means yet another source file that has to be kept in sync with everything else.
If there's already a method for doing this, please let me know. Otherwise consider this a feature request.
You may find graphqlgen from Prisma helpful: https://github.com/prisma/graphqlgen
If you decide to evaluate graphqlgen, I would also recommend trying that as well: https://graphql-code-generator.com
If you decide to evaluate graphqlgen, I would also recommend trying that as well: https://graphql-code-generator.com
Yep, that's what I am using. Works great!
Most helpful comment
Yep, that's what I am using. Works great!