GraphQL is a powerful technology that lets you query the exact data that you need when you need it on your front end. Strapi allows for GraphQL integration through a plugin.
You can install GraphQL with the following command:
yarn strapi install graphql
You'll notice this adds GraphQL in your plugins tab within Strapi.
When that is installed you can navigate to
/graphql in your Strapi project and query the data you have.
Instructor: [0:00] Using Strapi, one can leverage GraphQL to get data from your CMS. To do this, we'll go to our terminal and stop our Strapi app, we'll check our directory, and inside your API folder, type the command, yarn strapi install graphql. Once our GraphQL plugin is installed, we'll restart our server with yarn develop. Now we can access our plugin.
[0:28] In the Strapi dashboard, under Plugins, you should now see GraphQL. In our other browser, we'll go to localhost:1337/graphql. Now we have access to our GraphQL Playground. We'll type query, to put together a query. Inside that, we want to access our posts. Inside posts, we have data attributes, and in that, we have access to our title and author.
[0:54] When we click Play, we make our request and execute the query, and get a response of the title and author as expected. The GraphQL Playground also has access to the API documentation for different queries and mutations, as well as your GraphQL schema. That is how you install and use GraphQL in Strapi.
Hi Daniel, really enjoying your course! Even the examples are great! Wanted to ask, which version of yarn are you using? Is there a specific version of yarn that´s recommended for use with a Strapi project? Thanks for a great course!