This boilerplate uses the GraphQL API when the GraphQL plugin is installed in your project.
cd react-apollo
npm install
npm start
⚠️ Make sure you're using MongoDB as a database.
In your Strapi project run the following:
strapi generate:api product
strapi install graphql
then in your /api/product/model/Product.settings.json
copy-paste the following:
{
"connection": "default",
"collectionName": "",
"info": {
"name": "product",
"description": ""
},
"attributes": {
"name": {
"type": "string"
},
"description": {
"type": "text"
}
}
}
Register the admin user in Strapi and you're good to go.
You can fetch data in two different ways (both are implemented)
- using the
<Query />
component (see theProductDetailsPage
) - manually using the client that is exported (see the
EditPage
)
The cache is disabled since mutations
are not implemented yet, so if you need to mutate data you have to disable it for the moment.
This option is located in the apollo-client.js
file.
Since mutations aren't available yet, we use the request helper.