Is your feature request related to a problem? Please describe.
The TypeScript-Gatsby support here is great! However, there is a significant portion of Gatsby apps that are not covered via graphql-codegen:
This would be any await graphql(/* .... */) calls as part of gatsby'screatePages node API. This API is essential for creating pages programmatically using GraphQL.
The problem here is that graphql-code-generator (afaik) currently has no ability to generate types for this call so the result of await graphql is untyped.
Describe the solution you'd like
I think it makes sense to either:
@graphql-codegen/typescript-operations to include support for graphql(/* query */)gatsby-node's graphql(/* query */) callsI don't know if these options make sense but the goal is output operation types for gatsby-node calls.
Describe alternatives you've considered
stated alternative ideas above.
Additional context
I've tried writing a plugin myself that correctly parses the graphql(/* ... */) calls however it seems like graphql-codegen won't recognize/load any *.ts file (with error Unable to find any GraphQL type definitions for the following pointers:) unless it includes some known import like these:
any-ts-file.ts
import { graphql } from 'gatsby';
// or
import graphql from 'graphql-tag';
This constraint leads me to believe this kind of behavior can't be done with only plugins.
Could you add pluckConfig like below and try again? This configuration would set 'graphql' as a default tag name instead of 'gql'.
pluckConfig:
globalGqlIdentifierName: graphql
@ardatan oh my lord, it worked
@ricokahler Awesome! I think both gql and graphql should be default identifiers. Let's keep this open until we do these changes!
that was easier than I thought. thanks for the support!
https://github.com/ardatan/graphql-toolkit/commit/4e615bdad560c65d6864f56ff2deaf4282659c7b
In the next release of both toolkit and codegen, you won't need this extra configuration.
Available in v1.12.0
Most helpful comment
https://github.com/ardatan/graphql-toolkit/commit/4e615bdad560c65d6864f56ff2deaf4282659c7b
In the next release of both toolkit and codegen, you won't need this extra configuration.