gatsby-uc / gatsby-source-strapi

Gatsby source plugin for building websites using Strapi as a data source
MIT License
355 stars 183 forks source link

Bump: Really Need Help w/ singleTypes please! #143

Closed outspokeio closed 1 year ago

outspokeio commented 4 years ago

Hello and thank you for your support. I moved my organization from a Wordpress framework to Strapi/Gatsby and a big part of the "sell" was the use of singleTypes to create re-usable components that match front end display components in Gatsby.

No matter what I try I cannot get singleTypes to work in my repo(s). I have existing contentType queries that run off basic syntax. When I add the simplest of singleTypes collections it breaks my existing queries... which run fine without the "singleTypes: ['testSingle']" line.

Relevant info:

{
  resolve: `gatsby-source-strapi`,
  options: {
    apiURL: `<OUR URL>`,
    queryLimit: 1000, // Default to 100
    contentTypes: [`articles`, `ads`],
    singleTypes: [`testSingle`],
    // Possibility to login with a strapi user, when content types are not publically available (optional).
  },
},

In Strapi: Single Type name = testSingle Collection name = testSingle (NOTE: This consists of a single text field... with the value "test1234").

Error I get when adding the singleTypes: ['testSingle'] line to the above config:

"gatsby-source-strapi" threw an error while running the sourceNodes lifecycle:

Request failed with status code 404

then.. as a result: Cannot query field "allStrapiArticles" on type "Query".

NOTE: All permissions on this for both auth and public user types are checked. However - I did notice that for the singleType collections there are only 3 methods available -> delete, find and update. I imagine find is all we need but just pointing it out for the sake of inclusiveness.

I've spent a solid few hours trying to troubleshoot this. Hoping someone here can help! Don't want to give the Wordpress contingent any reason to push back on our use of Strapi.

Thank you!

SimonThormeyer commented 4 years ago

How did you write your queries? Sure you did everything right? I recommend using the GraphiQL tool and just copy paste your working query from there.

cptcrunchy commented 4 years ago

Check the version of gatsby-source-strapi. I was running into the same issue and I had version 0.0.10 which was not working with singleTypes. I upgrade to 0.0.12 and I was able to view single types in Graphql

gkubiak92 commented 3 years ago

@outspokeio I encountered similar problem. There are some steps you can try to fix your problem:

  1. Go to strapi graphql page (in my case in development :http://localhost:1337/graphql)
  2. Look at the docs on the right side and see if there are your single types (if yes that's good)
  3. Try to query something from some single type (in my case I got permission problem here)
  4. If in point 3 you will get permission error, Gatsby plugin cannot get this data also. Now go to Strapi admin panel > settings > roles > public and here try to change some single types permissions to at least "find". In my case this was the reason of similar problem that Gatsby plugin couldn't fetch data from strapi and create graphQL schemas.
moonmeister commented 1 year ago

Thanks for your interest in this project. This plugin is moving into the Gatsby User Collective and this repo will be archived. Please open an issue in that repository, submit a PR if you'd like to see this implemented, or join us on Discord if you have questions!