Search code examples
reactjsgraphqlgatsbycontent-typestrapi

Strapi isn't showing both Content Types on GraphQL


Context: I'm building a basic blog with Strapi+Gatsby following this tutorial.

Problem: I've created the Content Types 'Category' and 'Post' (called 'Article' in the tutorial), 'Post' has a Relation Field to relate both Content Types ('Category' has many 'Posts'). When trying to access these Content Types via graphQL (localhost:xxxx/___graphql) I can't see 'Categories', I just see 'Posts'.

GraphQl

I would like to query 'Category' the same way I'm querying 'Post':

GraphQl Query

And I've noticed that 'Post' has a component called 'Category' because of the Relation Field.

Any idea on why is 'Category' not showing?


Solution

  • To show both Content Types they both have to be indicated in the plugin configuration [rookie mistake, sorry for the question]:

    resolve: "gatsby-source-strapi",
    options: {     
        apiUrl: process.env.API_URL,
        contentTypes: ["category", "article"],
        queryLimit: 1000,
    }