-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced support for page queries/components #74
Comments
Hi @cometkim, thanks for a great library 😄 I was curious if there's any way to type the data prop from a page query automatically at the moment? And whether there's some workaround for this until the actual you ship this feature? EDIT: I realized I can just type the components as |
Hi @sanjaypojo, thanks for your interest in this issue :) The data fields can easily be typed with the query type already generated, as you mentioned. Actually, pageContext also has a generated type, but the problem is that all page contexts are merged into one single type; So it needs some static analysis of the |
And, I found it inconvenient to include a lot of nullability in the generated type because the Gatsby schema is inferred fields as Nullable if not explicitly declared as non-null. For now, the best way to solve this is to write a type guard user self, but it is too cumbersome. And it is not an option to manipulate the schema arbitrarily or to cheat the type. To do this, I first aim to create a type guard function that can be used in general. And then provide a basic practice for typing page queries through it. |
Oh, I just realized gatsby already provides some utility types for page props https://github.com/gatsbyjs/gatsby/blob/a72caa67f8/packages/gatsby/index.d.ts#L33-L120 |
The text was updated successfully, but these errors were encountered: