Skip to content
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

How to use TypedDocumentNode (or DocumentNode) in Shopify Admin GraphQL #753

Open
ErikTheBerik opened this issue Apr 3, 2024 · 2 comments
Labels

Comments

@ErikTheBerik
Copy link

ErikTheBerik commented Apr 3, 2024

Overview

I'm not sure if this is where I should post this or if this is already possible. But I've tried all day and I couldn't make this work. I want to have intellisense with graphql like here: "https://the-guild.dev/blog/typed-document-node".

I am using the shopify GraphqlClient from "@shopify/shopify-api/lib/clients/admin/graphql/client" and I want to run a graphql query with DocumentNode or TypedDocumentNode so I can get some intellisense. So can I do this?

In terms of having typed graphql with shopify I've only found this "https://shopify.dev/docs/api/shopify-app-remix/v2/guide-graphql-types" which uses "@shopify/api-codegen-preset" but I'd like to store my graphql queries in a .graphql file and use codegen to "compile" them (like in typed-document-node).

@paulomarg
Copy link
Contributor

Hey, thanks for raising this. We currently don't support TypedDocumentNodes as inputs to the queries - the way our preset package works is that it will map the query string to the types, and the client will automatically load them. The main gain we have here is that we don't need to parse the query into a node at all, which means there's no impact on performance.

The downside of this is that it only works if the query is string defined as const, so that the typing sticks, but it also has no impact on production.

We can maybe look into supporting nodes as a parameter to better cover your case, but unfortunately, that is not something we'll be able to do soon as there are other things that will be a higher priority.

Hope this helps!

@paulomarg paulomarg transferred this issue from Shopify/shopify-api-js Apr 11, 2024
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants