Gatsby: plugin `gatsby-source-contentful` - Unexpected Name "Contentful"

Created on 8 Jun 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Description

gatsby-source-contentful fall with error in newly created gatsby site

Steps to reproduce

  • gatsby new contentful-blog
  • cd contentful-blog
  • yarn add gatsby-source-contentful
  • add contentful plugin
{
      resolve: `gatsby-source-contentful`,
      options: {
        spaceId: `*space*`,
        accessToken: "*token*",
      },
    },
  • gatsby develop

Expected result

successful build and Contentful nodes created

Actual result

Build failed with error

```
GraphQLError: Syntax Error: Unexpected Name "Contentful"

  • TypeMapper.js:113 TypeMapper.createType
    [kid-davinci]/[graphql-compose]/lib/TypeMapper.js:113:43

  • ObjectTypeComposer.js:80 Function.createTemp
    [kid-davinci]/[graphql-compose]/lib/ObjectTypeComposer.js:80:28

  • ObjectTypeComposer.js:56 Function.create
    [kid-davinci]/[graphql-compose]/lib/ObjectTypeComposer.js:56:21

  • index.js:47 typeNames.forEach.typeName
    [kid-davinci]/[gatsby]/dist/schema/infer/index.js:47:41

  • Array.forEach

  • index.js:30 addInferredTypes
    [kid-davinci]/[gatsby]/dist/schema/infer/index.js:30:13

  • schema.js:143
    [kid-davinci]/[gatsby]/dist/schema/schema.js:143:11

  • Generator.next

### Environment

System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.11.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 74.0.3729.169
Firefox: 67.0
Safari: 12.1.1
npmPackages:
gatsby: ^2.8.6 => 2.8.6
gatsby-image: ^2.1.2 => 2.1.2
gatsby-plugin-catch-links: ^2.0.13 => 2.0.13
gatsby-plugin-manifest: ^2.0.29 => 2.0.29
gatsby-plugin-offline: ^2.0.25 => 2.0.25
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-s3: ^0.2.5 => 0.2.5
gatsby-plugin-sharp: ^2.0.35 => 2.0.35
gatsby-plugin-styled-components: ^3.0.7 => 3.0.7
gatsby-source-contentful: ^2.0.67 => 2.0.67
gatsby-source-filesystem: ^2.0.33 => 2.0.33
gatsby-source-prismic: ^2.3.0-alpha.3 => 2.3.0-alpha.3
gatsby-transformer-sharp: ^2.1.18 => 2.1.18
gatsby-transformer-yaml: ^2.1.12 => 2.1.12
npmGlobalPackages:
gatsby-cli: 2.5.12
```

stale?

Most helpful comment

i got why this issue occurrence, i entered "Name" of Content Type with cyrillic char's
and contentful plugin use "Name" to create graphql types

All 5 comments

i got why this issue occurrence, i entered "Name" of Content Type with cyrillic char's
and contentful plugin use "Name" to create graphql types

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.

Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@DimaKoval thanks for the clue. In my case we tried to follow some example of Content Infrastructure, where they prepended each Content Type with specific emojis.

So it was something like "#锔忊儯-topic-Article" for Topic types and "鈿欙笍-component-Page" for component/assembly types.

It was also failing. I am wondering, why don't they use Content type ID, so it will already be validated by Contentful.

I was getting the same problem with Japanese character type names, too.

I am wondering, why don't they use Content type ID

Configuring useNameForId: false works for me 馃憤

useNameForId [boolean][optional] [default: true]

Use the content's name when generating the GraphQL schema e.g. a Content Type called [Component] Navigation bar will be named contentfulComponentNavigationBar.

When set to false, the content's internal ID will be used instead e.g. a Content Type with the ID navigationBar will be called contentfulNavigationBar.

Using the ID is a much more stable property to work with as it will change less often. However, in some scenarios, Content Types' IDs will be auto-generated (e.g. when creating a new Content Type without specifying an ID) which means the name in the GraphQL schema will be something like contentfulC6XwpTaSiiI2Ak2Ww0oi6qa. This won't change and will still function perfectly as a valid field name but it is obviously pretty ugly to work with.

If you are confident your Content Types will have natural-language IDs (e.g. blogPost), then you should set this option to false. If you are unable to ensure this, then you should leave this option set to true (the default).

https://github.com/gatsbyjs/gatsby/blob/5db8758c88356d80797c7473295c3d431c9bb192/packages/gatsby-source-contentful/README.md

Was this page helpful?
0 / 5 - 0 ratings