-
Notifications
You must be signed in to change notification settings - Fork 474
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
Improved GraphQL client #672
Conversation
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.
This is awesome, I think you can update the GraphQL docs to use your Just saw your PR description TODO. 👏ShopifyAPI::GraphQL.client
instead of ShopifyAPI::GraphQL.new
.
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.
Looks good to me, I would prefer to have the migration guide and docs on setting up the schema in before we release the version with this functionality in it.
Updated with:
👀 appreciated |
7bc2509
to
ab80075
Compare
ab80075
to
d6295ff
Compare
@alanhill helped 🎩 this and got it all working upgrading a real app 🎉 With his help we found some issues with the rake task so they've all been fixed now. |
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.
LGTM 🎉
This is a complete rewrite of the GraphQL client functionality. The previous implementation suffered from a few problems making it virtually unusable as detailed in #511. Here's a summary: 1. you couldn't specify a local schema file 2. due to the above, the client made a dynamic introspection request on initialization which was very slow 3. unbounded memory growth due to building new clients at runtime This rewrite was focused on solving those problems first and foremost but we also had a few other goals: * support API versioning * provide better defaults and an improved developer experience * ensure it's impossible to do the wrong thing The new GraphQL client *only* supports loading local schema files to ensure no introspection requests are made during app runtime. The goal is that clients are fully initialized at application boot time (and if you're using Rails this is handled automatically). Workflow: 1. Set `ShopifyAPI::GraphQL.schema_location` to a directory path (or use the default in Rails of `db/shopify_graphql_schemas`). 2. Save a JSON version of Shopify's Admin schema locally (or use the `shopify_api:graphql:dump` Rake task) to the `schema_location` and name it after the API version: `2020-01.json`. 3. Access the client at `ShopifyAPI::GraphQL.client` 4. Execute queries via `client.query`
* Fixes Rails `environment` task prereq * Does a preflight request to ensure authentication works * Improved output
b41d875
to
de79d8c
Compare
This is a complete rewrite of the GraphQL client functionality.
The previous implementation suffered from a few problems making it virtually unusable as detailed in #511. Here's a summary:
This rewrite was focused on solving those problems first and foremost but we also had a few other goals:
The new GraphQL client only supports loading local schema files to ensure no introspection requests are made during app runtime. The goal is that clients are fully initialized at application boot time (and if you're using Rails this is handled automatically).
Workflow:
ShopifyAPI::GraphQL.schema_location
to a directory path (or use the default in Rails ofdb/shopify_graphql_schemas
).shopify_api:graphql:dump
Rake task) to theschema_location
and name it after the API version:2020-01.json
.ShopifyAPI::GraphQL.client
client.query
Rails integration
All the new features are designed to work independently of Rails but there are a few additional integration points:
schema_location
is set to be Rails specific withindb/
environment
task prerequisiteMigration
If anyone is using the current GraphQL client it's very easy to migrate to this new one.
Previously a client was initialized with
ShopifyAPI::GraphQL.new
:Now you use
ShopifyAPI::GraphQL.client
which has already been initialized:Todo