d
Topic
Posts:
22
7 days ago

GraphiQL Export

I added the GraphiQL app to my store but don't see how to export the result of a query. How is this done and what, if any, formats are available.

Do I need to write a program on my computer to make an http request and get JSON back to accomplish this?

i
Replies
Posts:
469
7 days ago

Hi David,

Could you please provide a link to the GraphiQL app? I am not aware or cannot find any Shopify app that wraps GraphiQL browser.

Thanks!

I turn coffee in to code - since 1998
Posts:
22
7 days ago
Posts:
469
7 days ago

Ah cool, thanks. Okay, so that basically gives you GraphiQL from within your store admin to explore the API. But it is just that, for exploring.

I usually prefer to explore using Playground or Insomnia as they offer much more and no need to install an app to clutter your admin.

But to use any of those GraphQL queries and their results, you will need a server application that has access to the endpoints using the key and pwd you setup in your private app or app. Unless you're using Storefront API where you can access via key alone and use a browser based GraphQL client library.

Hope this helps (or adds to the confusion :D )

I turn coffee in to code - since 1998
Posts:
22
7 days ago

So to access shopify data I would need a program on my computer that makes an http request or use Playground or Insomnia?

Can Playground or Insomnia allow me to retrieve and download data to my computer or format a report?

Where would I find the key and pwd?

Posts:
469
7 days ago

Urm... David, I appreciate your curiousity here, but all of this is documented either by Shopify or documentation of the tools mentioned above. I suggest brewing a bucket full of coffee and reading... a lot :)

I turn coffee in to code - since 1998
Posts:
22
7 days ago

We just set up a store and it sounds like there's a LOT to learn. Thanks for all your comments.

Posts:
469
7 days ago

Keep on it and enjoy. If you run in to any sort of trouble with some specific problem, the forum can help.

Best wishes

I turn coffee in to code - since 1998
Posts:
17
7 days ago

David, although GraphiQL can be used in the way you described (querying for data as a store owner) it is, like Karl mentioned, just for exploring the API and should not be seen as a data mining / exporting tool. 

If you would like to use the API properly (without writing applications) you will have to:

1) get authentication credentials (investigate Private Apps)
2) Use some flavor of an API Dev Environment (ie: Postman) to make your API requests using the relevant endpoints. (investigate API authentication headers)

This will always return results in JSON format. If you require the data in any other format, you will need to do additional processing yourself. This is best accomplished by building / having an app built to suit your requirements. Working with pure JSON as a store owner is messy and I would strongly advise you to approach an app developer instead. 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
Posts:
1141
7 days ago

We just set up a store ....

even though this is the api subforum, that seems conflit with the opening post

I added the GraphiQL app to my store but don't see how to export the result of a query. How is this done ....

So sidestepping graphql for a moment, what data are you trying to get and why? what are you trying to accomplish

Busy? Confused? Hire me to do it for you paull.newton+shopifyforum@gmail.com . Theme Customization,Modification,Repair, CSS,javascript,html. App dev. Consultant, Discovery Services http://www.krop.com/paulnewton/ . Want to buy me a coffee paypal.me/paulnewton
Posts:
22
Last edited 7 days ago

We want daily detailed reports like

DATE, TIME, DISCOUNT CODE, STATE, CITY, ZIP CODE, ORDER AMOUNT

sorted by DATE and TIME, as well as weekly and monthly summarized reports like

DISCOUNT CODE, NUMBER OF ORDERS, ORDER AMOUNT

sorted by DISCOUNT CODE.

Additional columns may be added later but this is a start.

Doing things like this with SQL are fairly simple, even when multiple tables are involved, but it seems to be a chore to accomplish this with shopify.

Posts:
17
7 days ago
g
1
upvotes

Doing things like this with SQL are fairly simple, even when multiple tables are involved, but it seems to be a chore to accomplish this with shopify.

I'm sure a lot of us would LOVE having SQL access, but you can't really expect a company like Shopify (or any for that matter) to make their whole DB schema public knowledge. Having GraphQL is one step closer than the normal REST API though. 

I think MS Excel has a JSON import feature nowadays. Might be something to look into if you want to process the data yourself. 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
Posts:
469
7 days ago
g
1
upvotes

Well, to someone who has never used SQL it would be very much the same chore. I won't claim that all is peaches using Shopify, but neither is using any relational database and blieve me do, I've had my fair share of those. It's just a matter of understanding the technologies, the tools, the domain and limitations or even flaws in order to find the best solution for the given circumstances.

In your case, the solution could be very simple or very over-engineered. It's just a matter of how you want to solve it.

For instance, you could achieve above in 2 steps

Step 1

$ curl -i -X POST \
"https://<MY_STORE>.shopify.com/admin/api/graphql.json" \
-H 'Content-Type: application/json' \
-H "X-Shopify-Access-Token: <ACCESS_TOKEN>"
-d '
{
  orders(first: 250, query:"created_at:>2018-11-30 created_at:<2018-11-31") {
    edges {
      node {
        name
        discountCode
        createdAt
        totalPriceSet { shopMoney { amount currencyCode } }
        shippingAddress { province city zip }
      }
    }
  }
}
' >> output.json

Step 2

MS Excel connect to JSON data source

Done and dusted. Surely a lot simpler than SQL. Now you could do bash scripts, write apps with or without servers, and over engineer as much as you like and must, but I wouldn't blame Shopify or GraphQL no more ;-)

Hope this helps!

I turn coffee in to code - since 1998
Posts:
469
7 days ago

Aye, Billy Griffiths beat me to it with Excel ;-)

I turn coffee in to code - since 1998
Posts:
22
6 days ago

Nice example with curl! Where do I find or create a shopify access token?

Posts:
469
6 days ago

I turn coffee in to code - since 1998
Posts:
22
6 days ago

After a lot of searching I finally found how to create a storefront access token. Should your curl example use

X-Shopify-Storefront-Access-Token

instead of

X-Shopify-Access-Token

If not, how do I create an access token?

Posts:
1141
6 days ago

If not, how do I create an access token?

Check the shopify Oauth help docs, you may want to go through the creating an app tutorials so the auth flow is clearer

Busy? Confused? Hire me to do it for you paull.newton+shopifyforum@gmail.com . Theme Customization,Modification,Repair, CSS,javascript,html. App dev. Consultant, Discovery Services http://www.krop.com/paulnewton/ . Want to buy me a coffee paypal.me/paulnewton
Posts:
22
5 days ago

Thanks, but my question is whether to use X-Shopify-Storefront-Access-Token or X-Shopify-Access-Token in Karl's curl example. I created a storefront access token and am not sure if there is an error in the curl example or if a storefront access token is different than an access token.

 

Posts:
469
5 days ago

Hi David,

I think there's a clear distinction between helping people by offering advice or answers that point them in the right direction, get them unstuck or highlight a small error - and - just completing it for them from start to finish. Former is called a student. Latter is called a client.

I have, as have others, offered help where to find the right documentation, tutorials as well as some advice and tid bits of code to ease you in to Shopify. I can only suggest you thoroughly read all the tutorials, browse the forum for past questions and answers, study the documentation and foremost, try yourself. Don't rush it and allow yourself a lot of time for this process - there are no shortcuts. If that doesn't sound like something you're willing to do and you'd rather have exact answers and solutions provided, I suggest you look at hiring a Shopify Expert.

p.s. Storefront API and GraphQL Admin API are two entirely different APIs and so are their authentication mechanisms - which you would find out by reading the documentation.

Best regards

I turn coffee in to code - since 1998
Posts:
1141
5 days ago
g
1
upvotes

We want daily detailed reports like

The storefront api is not what you want as that is a more public facing service to build frontends, so there will be some data you just can't access for privacy and security reasons. For example inventory_quantity i a public no no. 

Thanks, but my question is whether to use X-Shopify-Storefront-Access-Token or X-Shopify-Access-Token in Karl's curl example. 

You asked how to create an auth token I quoted it verbatim, and that question translates to you need to read more beginners documentation(or search forums) on oauth and storefront api because foundational knowledge is missing where an hour of personal reading will prevent DAYS of back and forth posts by volunteers. Like knowing  the storefront api is publicly unauthenticated can save weeks of developer effort.

Then ask clarifying questions.

Example post https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/how-to-get-access-to-the-new-storefront-api-430874

Clarification: Graphql is the syntax that both the storefront and graphql-admin use as opposed to the depreciating REST api's.

 

 

Busy? Confused? Hire me to do it for you paull.newton+shopifyforum@gmail.com . Theme Customization,Modification,Repair, CSS,javascript,html. App dev. Consultant, Discovery Services http://www.krop.com/paulnewton/ . Want to buy me a coffee paypal.me/paulnewton