![]() We’ll take a look a closer look at cost another time, so for now don’t worry about it. “Extensions” is extra information that Shopify has added, such as the cost of your query.“Data” is always what you’ve just requested in your query.You might notice that you get what you asked for, and then some. In the returned JSON payload, you should see two top level keys: “data,” and “extensions.” Query to get the Shop object with some fields. This query gets the Shop object, and specifies which fields we want returned. In GraphQL, we always have to select what we want to have returned to us from the available fields. Alternatively, Insomnia will auto-complete valid fields as you type when selecting fields, so feel free to modify the query below to get more or less information back. In our example, we'll take another look at the Shop resource, since it is a single object. Objects represent concepts such as the Shop, or a single Order, and contain data in fields. To use this page, search the page for a resource that interests you, and click through to learn more. The QueryRoot represents easily accessible entry points into the GraphQL Admin API graph. Let’s start by learning how we can structure our queries to get the most out of GraphQL. Run the query to get your shop’s name back. Once you've set up these two fields in your environment, try running the below query. You should get your shop’s name back. Ensure you have the right environment selected. If you don’t see your values, ensure you have the right environment selected. Hovering over either of these should show you the value that will be substituted into the request. You can also click Header at the top to see which headers we are sending with our request, including the access_token. You should see at the top of the frame that we're using the "store" to build out the address for the endpoint. In Insomnia, open the second query, under Shopify GraphQL Walkthrough > Insomnia Configuration, titled Run the rest query. Add your details to the my-test-store-details sub-environment. You can set your environment variables by opening the Manage Environments window, and adding your details to the my-test-store-details sub-environment: Open the Manage Environments window. These will enable you to re-use all the queries in this collection with different Shopify stores, just by changing your Insomnia environment variables. ![]() Your private app’s password visible on your app page. This is your private app’s password, visible on that app’s page.If your store is, enter “mydevstore” here.Step 2: Configure your environment variablesĮnvironment variables are JSON key-value pairs that allow you to refer to values without having to write them out every time.įor our setup, we'll define two environment variables: Open the Import/Export window in Insomnia:įrom the Data tab, browse to the collection: Once you’ve downloaded the walkthrough as a collection, you’ll need to import it into Insomnia. Once you’ve installed Insomnia, you’ll need to import the collection and ensure it is properly configured to make calls to your store using your API credentials. Personally, I always expected it to be editable, and I just realized with these tests that it would be a great solution, for me at least.Head on over to the gist linked below to copy the requests directly without having to use Insomnia. Would it be hard to change this Preview into an editable input? This lead me to think about the current environment variable form that is accessed when you click on a variable tag ( base_url in my screenshot above).Ĭurrently, it shows an enum (select) of available variables, and a preview of the selected variable. This works, but this is not really practical.
0 Comments
Leave a Reply. |