Use case – Enabling GraphQL for our API
So far, we've been consuming our API through a RESTful interface. We've added support for generating documentation in the previous section through the Documentation plugin. GraphQL is becoming an increasingly popular alternative to REST, and one of its many benefits is that generates schemas for our types that serve as documentation that is always up to date and reflects the current state of our content-types.
To support GraphQL in our Strapi API, we can simply install a plugin that enables a GraphQL endpoint to interact with our content and automatically generates all the GraphQL schema for our content-types.
Let's go ahead and install the plugin with the following command:
yarn strapi install graphql
Now, if we start our Strapi instance with yarn develop
and open our browser at http://localhost:1337/graphql
, we should see GraphQL Playground in the browser. GraphQL Playground is a visual interface that allows...