-
Notifications
You must be signed in to change notification settings - Fork 283
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
Support Customer Account API in GraphiQL #1693
Conversation
This comment has been minimized.
This comment has been minimized.
@@ -91,21 +91,42 @@ export function createCustomerAccountClient({ | |||
url.protocol === 'http:' ? url.origin.replace('http', 'https') : url.origin; | |||
const redirectUri = authUrl.startsWith('/') ? origin + authUrl : authUrl; | |||
|
|||
const customerAccountApiUrl = `${customerAccountUrl}/account/customer/api/${customerApiVersion}/graphql`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a bunch of similar changes in #1684
// CustomerAccount API does not support introspection to the same URL. | ||
// Read it from a file using the asset server: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@s-lee-kwong Can we add introspection to the graphql end point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is something we can look at but right now our only introspection point is something like
https://app.myshopify.com/services/graphql/introspection/customer?api_client_api_key=159a99b8a7289a72f68603f2f4de40ac&api_version=2024-01
but that api_key is from an app so I wouldn't use what I pasted exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GraphiQL can only work with 1 url for both introspection and queries. So if you want to add support for GraphiQL in CAAPI, the URL for queries should also provide introspection 🙏
Here we had to work around this issue by downloading the schema in a different way and providing it to GarphiQL in JSON format without doing introspection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add this to the on going Friction Doc for the future.
Having the introspection and queries be at the same URL is a fairly standard way of implementation for GraphQL API. A lot of the tools work assuming this convention and it would be really good to have.
@@ -53,6 +53,8 @@ export type CustomerClient = { | |||
handleAuthStatus: () => void | DataFunctionValue; | |||
/** Returns CustomerAccessToken if the customer is logged in. It also run a expiry check and does a token refresh if needed. */ | |||
getAccessToken: () => Promise<string | undefined>; | |||
/** Creates the fully-qualified URL to your store's GraphQL endpoint.*/ | |||
getApiUrl: () => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder to add this to the Doc type below as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩 and it looks great! Just missing a type.
Slightly wonder if we should list out both Storefront API
and Customer Account API
in the UI with selected state or maybe a drop down? The interaction of tabbing on the text to switch API is not super clear to me.
Also future task! would love to bring in a documentation explore for the schema!
|
Add support for multiple schemas in GraphiQL and a way to update schema automatically when changing tabs.
Open GraphiQL clicking on links from the Subrequest Profiler.