This forum has moved, please join us on github discussions. We will keep these old posts available for reference. Thank you!

Consume GraphQL JSON

Hey there. Just taking a first look at this. Is anyone consuming GraphQL API to populate Apostrophe components? I want to consume Commerce API and use Apostrophe for rendering layer.

Hi duselton, what “commerce API” are you referring to?

npm has excellent libraries for GraphQL, so no reason you couldn’t use those in an Apostrophe module, for instance in an apostrophe-pages:beforeSend event handler, and push data into req.data for consumption in the page template.

I am thinking of using Magento GraphQL API…

Looks like you can use any client library you like for making GraphQL queries. Axios is nice.

Put that together with apostrophe’s promise events and you’ll have a place to call it from:

https://docs.apostrophecms.org/apostrophe/advanced-topics/promise-events/promise-events

Hope this is helpful!