datocms / gatsby-source-datocms

Official GatsbyJS source plugin to pull content from DatoCMS
MIT License
140 stars 51 forks source link

Lots of errors when adding the plugin into a new site #86

Closed codigoconjuan closed 4 years ago

codigoconjuan commented 4 years ago

So once i add gatsby-source-datocms i get a bunch of errors on my terminal similar to:

ERROR #85901 GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsFluid".

File: node_modules/gatsby-source-datocms/fragments/asset.js:114:43

if i remove gatsby-source-datocms it works fine, not really sure if i'm missing something since i installed the gatsby-source-datocms and then added the information into the gatsby-config.js file according to the docs

codigoconjuan commented 4 years ago

also ⠦ loading DatoCMS content in the terminal takes forever (probably because of the above errors)

already tried to install a previous version and also I updated my dependencies to the latest version (fresh website but gatsby didn't install the latest version in my dependencies file)

matjack1 commented 4 years ago

Hey @juanpablogdl sorry to hear that!

I cannot reproduce on my machine, can you please share some details on your operating system, Node version, Gatsby version and gatsby-source-datocms version?

Thank you!

stefanoverna commented 4 years ago

The best would be if you could share a repo @juanpablogdl

wispyco commented 4 years ago

I'm actually running into the same issue with a brand new repo. The last project I used the gatsby datocms starter from gatsby cloud, but I wanted to try this one from scratch.

Here is my system

 System:
    OS: Linux 4.4 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
    Shell: 4.4.19 - /bin/bash
  Binaries:
    Node: 13.5.0 - ~/.nvm/versions/node/v13.5.0/bin/node
    npm: 6.13.4 - ~/.nvm/versions/node/v13.5.0/bin/npm
  npmPackages:
    gatsby: ^2.18.12 => 2.18.12
    gatsby-image: ^2.2.34 => 2.2.34
    gatsby-plugin-manifest: ^2.2.31 => 2.2.31
    gatsby-plugin-offline: ^3.0.27 => 3.0.27
    gatsby-plugin-react-helmet: ^3.1.16 => 3.1.16
    gatsby-plugin-sharp: ^2.3.5 => 2.3.5
    gatsby-source-datocms: ^2.1.22 => 2.1.22
    gatsby-source-filesystem: ^2.1.40 => 2.1.40
    gatsby-transformer-sharp: ^2.3.7 => 2.3.7
  npmGlobalPackages:
    gatsby-cli: 2.8.22

and my live repo

https://github.com/wispyco/riel-portfolio-design

and here is a sample of the errors i am getting

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsSeoMetaTags".

File: node_modules/gatsby-source-datocms/fragments/seo.js:4:40

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsFaviconMetaTags".

File: node_modules/gatsby-source-datocms/fragments/favicon.js:4:44

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsFixed".

File: node_modules/gatsby-source-datocms/fragments/asset.js:4:40

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsFixed".

File: node_modules/gatsby-source-datocms/fragments/asset.js:14:50

 ERROR #85901  GRAPHQL

There was an error in your GraphQL query:

Unknown type "DatoCmsFixed".

File: node_modules/gatsby-source-datocms/fragments/asset.js:24:49

and after these errors, I just get a loading DatoCMS content forever...

wispyco commented 4 years ago

So what worked for me was two things first I had stored my API token in my .env file, so I needed require('dotenv').config(); at the top of my gatsby-config.js file and I also had to remove the apiUrl option in the resolved gatsby-source-datocms plugin. The combination of the two stopped the error, I tried just the require and it did not work, so as per a recommendation somewhere else I tried the removal of the apiUrl and Voila.

ringofkeys commented 4 years ago

Thanks for the solve @wispyco! I was able to leave the apiUrl in my gatsby-config file, and your clue to use the dotenv NPM package led me to this page on the Gatsby site on Environment Variables. They recommend using dotenv as well, but pass in an object to the config method:

require('dotenv').config({
  path: `.env.${process.env.NODE_ENV}`
})
goleary commented 4 years ago

I'm also running into this issue after generating my site using Gatsby Cloud.

image

This seems to be because the generated gatsby-config.js file does not contain an apiUrl: image

I have already added my API key to .env, but I'm not sure what to use for the apiUrl field. I've poked around my admin console (https://.admin.datocms.com/admin) and still am not sure what to use here.

stefanoverna commented 4 years ago

Hi!

Can you tell me which DatoCMS project are you trying to build with Gatsby, and which API token are you using?

All the best,

— Stefano Verna

DatoCMS

--- original message --- On January 3, 2020, 3:24 AM GMT+1 notifications@github.com wrote:

I'm also running into this issue after generating my site using Gatsby Cloud.

This seems to be because the generated gatsby-config.js file does not contain an apiUrl:

I have already added my API key to .env, but I'm not sure what to use for the apiUrl field. I've poked around my admin console (https://.admin.datocms.com/admin) and still am not sure what to use here.

You are receiving this because you commented.

Reply to this email directly, view it on GitHub, or unsubscribe. --- end of original message ---

goleary commented 4 years ago

@stefanoverna I messaged you on gitter. Don't really want to publicly post my token here.

goleary commented 4 years ago

still getting the INVALID_SITE error...can anyone help figure out what's going on?

goleary commented 4 years ago

Figured out what's wrong: the dotenv library fails when the .env file is UTF-16 encoding.

Since this is the default encoding when using the > or >> command in PowerShell the readme instructions will result in an unusable .env file in this enviroment.

issue on .env: https://github.com/motdotla/dotenv/issues/445

reference: https://stackoverflow.com/questions/19122755/output-echo-a-variable-to-a-text-file

stefanoverna commented 4 years ago

Great, closing the issue!