-
Notifications
You must be signed in to change notification settings - Fork 116
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
Admin API GraphQL Codegen does not generate types for scalars #1154
Comments
Hi @sleepdotexe this is a great issue description and a good suggestion. We'll take a look at what we can add to |
We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests. You can add a comment to remove the label if it's still relevant, and we can re-evaluate it. |
+1 |
We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests. You can add a comment to remove the label if it's still relevant, and we can re-evaluate it. |
Still an issue I would love to see resolved, not stale. |
Issue summary
Before opening this issue, I have:
@shopify/*
package and version:@shopify/[email protected]
@shopify/[email protected]
{ logger: { level: LogSeverity.Debug } }
in my configuration, when applicableI am using the GraphQL Codegen to automatically generate TypeScript types for my Shopify queries. I am running into issues using properties that have Scalar types, as these are shown as type
any
. For example,Product['created_at']
has typeany
, when it really should bestring
since it has the scalar type ofDateTime
which is an extension of a string.The helper functions from
@shopify/api-codegen-preset
don't seem to provide scalar types by default, nor any way to manually provide these types. Since these types are managed by Shopify and relate specifically to the API, it would make the most sense to me for these to be automatically provided by the helper setup functions.According to https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#scalars, it should theoretically be possible to provide scalars to the codegen.
Here is an example
.graphqlrc.ts
:Expected behavior
Using the
.graphqlrc.ts
above, the inbuilt Shopify Scalars should be automatically generated inadmin.types.d.ts
like so:...Which allows the properties to have correct types in files.
Actual behavior
The Shopify scalars have types of
any
....Which means properties are not typed correctly.
Steps to reproduce the problem
Product['createdAt']
).Debug logs
There is a temporary solution I've found – after using the
shopifyApiProject()
helper function, I managed to manually force the config to include scalars like so:This seems to work, as the
admin.types.d.ts
file now includes the expected types for scalars. However it's not my favourite solution since it relies on hardcoding the scalar types, and also updating them if they are change (or new scalars are added) in future. Additionally, I have to mutate the setup object and provide a hack-y union type to keep type safety.Could we have these scalars included by default? And if not, could we at least have a documented option added to the
shopifyApiProject
helper function that allows us to manually provide these without the workaround?The text was updated successfully, but these errors were encountered: