Install and Query GraphQL API in Strapi

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.

Read more here: Source link