Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

The gatsby-source-strapi plugin has generated no Gatsby nodes #40

Closed
theshire-io opened this issue Jan 4, 2019 · 18 comments
Closed

The gatsby-source-strapi plugin has generated no Gatsby nodes #40

theshire-io opened this issue Jan 4, 2019 · 18 comments

Comments

@theshire-io
Copy link

But there is no error.

success open and validate gatsby-configs — 0.011 s
success load plugins — 0.411 s
success onPreInit — 0.484 s
success delete html and css files from previous builds — 0.021 s
success initialize cache — 0.009 s
success copy gatsby files — 0.023 s
success onPreBootstrap — 0.007 s
⠂ source and transform nodesStarting to fetch data from Strapi (posts)
⡀ source and transform nodesFetch Strapi data: 176.250ms
warning The gatsby-source-strapi plugin has generated no Gatsby nodes. Do you need it?
success source and transform nodes — 0.254 s
success building schema — 0.434 s
success createPages — 0.001 s
success createPagesStatefully — 0.049 s
success onPreExtractQueries — 0.005 s
success update schema — 0.312 s
success extract queries from components — 0.247 s
success run graphql queries — 0.108 s — 8/8 75.45 queries/second
success write out page data — 0.005 s
success write out redirect data — 0.001 s
⠐ onPostBootstrapdone generating icons for manifest
success onPostBootstrap — 0.380 s

gatsby.config.js

    {
      resolve: `gatsby-source-strapi`,
      options: {
        apiURL: `https://redacted`,
        contentTypes: [`post`]
      },
    },

If I go to https://redacted/posts directly from the browser, it returns a json with the posts.

Permissions for Public

image

Graphqli

image

Any idea what could be wrong?

@tripox
Copy link

tripox commented Jan 6, 2019

warning The gatsby-source-strapi plugin has generated no Gatsby nodes. Do you need it?

I had same issue.
Specifying the loginData for the gatsby-source-strapi plugin solved the issue for me.

@theshire-io
Copy link
Author

Thank you very much @tripox , unfortunately that didn't fix it for me.

I added an authenticated user, set the post permissions, dded the login data but still no posts.

image

image

@tripox
Copy link

tripox commented Jan 6, 2019

Hmm, do you see anything like this in the log?

⠁ Authenticate Strapi user
⢀ source and transform nodesAuthenticate Strapi user: 249.329ms
Starting to fetch data from Strapi (posts)
Starting to fetch data from Strapi (users)

Pretty new to GatsbyJS and Strapi.

Have you tried to stop gatsby develop, delete .cache in the folder with your Gatsby project and then run gatsby develop again?

It doesn't listen for changes and only imports on the initial run.

Another wild guess would be adding port to the apiURL - my setup is pretty default, so I have http://localhost:1337

@javialon26
Copy link

Same here... After a research in the code, the plugin adds a limit query string in the request to strapi.
The query string is _limit=0 and strapi always return an empty array.

@FlorianMoser
Copy link

I have the same issue. After some investigation I saw that the plugin makes a request to http://localhost:1337/articles?_limit=0. As @javialon26 remarks, this query returns no results and therefore no nodes are generated.

IMO the limit filter query should be removed in line 37 of fetch.js.

@javialon26
Copy link

After fixing the limit issue, another error came up in nodes.js file. The node.id must be a string and in my case the id is numeric and Gatsby throws an error. I fixed the issue adding a String() to line 17 in nodes.js file.

In my strapi the DB backend is MySQL, maybe with mongo, this is not an issue.

@theshire-io
Copy link
Author

@javialon26 Same issue with the postgres backend, adding a String() solved it. Thank you.

@javialon26
Copy link

javialon26 commented Jan 9, 2019

I found another issue. If I import more than 1 content type, the id of each node collisions and only one content type is created.

This happens because in Gatsby the node id must be globally unique. Maybe this is not an issue with Mongo but in MySQL or Postgres (@theshire-io ) the content types ids are numbers.

I fixed this concatenating the type and the id in the nodes.js files (line 17).

@javialon26
Copy link

javialon26 commented Jan 9, 2019

See: #43 #44

@theshire-io
Copy link
Author

Thanks again @javialon26 !

@ntloi95
Copy link

ntloi95 commented Jan 11, 2019

@javialon26 Did you make a pull request?

@iamrenzx
Copy link

iamrenzx commented Feb 1, 2019

Having the same issue with postgres. the query limit is having some issues i tried @javialon26 fix now its working

@yasirhaleem
Copy link

37

Having the same issue removing limit doesn't work for me, any help ?

@yasirhaleem
Copy link

Ok, if you add contentTypes which doesn't exist in strapi, it will show this warning

@ostrgard
Copy link
Contributor

ostrgard commented Aug 5, 2020

Not sure if this is helpful to anyone, but I had a similar issue that was due to a specified singleType which I had not entered data into in Strapi.

@meleklassoued
Copy link

I have the same issue guys can you help me please

@soupette
Copy link
Contributor

I have the same issue guys can you help me please

Which Strapi version are you using? And which version of the gatsby-source-plugin?

@meleklassoued
Copy link

the last version I added the api word next to the collection type and it works .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests