Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-source-contentful/GraphQL throws error when using emojis in Contentful content type name #35824

Closed
2 tasks done
samuel99 opened this issue Jun 2, 2022 · 16 comments
Closed
2 tasks done
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-contentful Related to Gatsby's integration with Contentful topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@samuel99
Copy link

samuel99 commented Jun 2, 2022

Preliminary Checks

Description

I'm building my first Contentful project. In the Contentful demo setups they are using emojis in the content type names. I have also got this recommendation from a contentful representative. And it seems like a good idea to keep your content types organized:

image

The app should be run on GatsbyJS. So I initiated a

npx gatsby new gatsby-starter-contentful-homepage https://github.com/gatsbyjs/gatsby-starter-contentful-homepage

I have also setup the gatsby-config.js for gatsby-source-contentful like so:

{
      resolve: `gatsby-source-contentful`,
      options: {
        spaceId: process.env.CONTENTFUL_SPACE_ID,
        accessToken: process.env.CONTENTFUL_CDA_TOKEN,
      },
}

But when I run gatsby develop I get this GraphQL error. It seems like emojis can't be used in Contentful content type names together with Gatsby.

info Contentful: 0 deleted assets
info Creating 1 Contentful Link nodes
info Creating 1 Contentful ✨ Contact me form (not in beta) nodes
info Creating 1 Contentful ✨ Framework nodes
info Creating 1 Contentful ✨ Office nodes
info Creating 1 Contentful 🧩 Editorial card (not in beta) nodes
info Creating 7 Contentful 📄 Common page nodes
info Creating 4 Contentful ✨ Product structure item nodes
info Creating 1 Contentful 🧩 Category list nodes
info Creating 1 Contentful 🧩 Product list nodes
info Creating 1 Contentful 📑 Article page nodes
info Creating 1 Contentful ✨ Ecom common nodes
info Creating 1 Contentful 🧩 Cart nodes
info Creating 1 Contentful ✨ Checkout - Unloading nodes
info Creating 1 Contentful 🧩 Checkout nodes
info Creating 1 Contentful ✨ Checkout - Delivery time nodes
info Creating 1 Contentful ✨ Checkout - Delivery address nodes
info Creating 1 Contentful ✨ Checkout - Delivery recipient nodes
info Creating 1 Contentful 🧩 Favorites nodes
info Creating 1 Contentful 🧩 Rich text nodes
info Creating 1 Contentful 🧩 Order confirmed nodes
info Creating 6 Contentful asset nodes
success Contentful: Create nodes - 0.205s
success Contentful: Process data - 0.237s
success Checking for changed pages - 0.002s
success source and transform nodes - 1.098s

 ERROR 

Missing onError handler for invocation 'building-schema', error was 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but
"Contentful✨ContactMeFormNotInBeta" does not.'. Stacktrace was 'GraphQLError: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but
"Contentful✨ContactMeFormNotInBeta" does not.
    at isValidNameError (C:\customername\node_modules\graphql\utilities\assertValidName.js:42:12)
    at assertValidName (C:\customername\node_modules\graphql\utilities\assertValidName.js:21:15)
    at checkIsAllowedTypeName (C:\customername\node_modules\gatsby\src\schema\schema.js:619:3)
    at forEach (C:\customername\node_modules\gatsby\src\schema\schema.js:297:9)
    at Array.forEach (<anonymous>)
    at addTypes (C:\customername\node_modules\gatsby\src\schema\schema.js:258:9)
    at updateSchemaComposer (C:\customername\node_modules\gatsby\src\schema\schema.js:130:9)
    at buildSchema (C:\customername\node_modules\gatsby\src\schema\schema.js:71:9)
    at build (C:\customername\node_modules\gatsby\src\schema\index.js:112:18)
    at buildSchema (C:\customername\node_modules\gatsby\src\services\build-schema.ts:19:3)'

Is this a bug in gatsby-source-contentful? It seems like the plugin is not sanitizing the content type names before adding them to the GraphQL schema.

Reproduction Link

https://github.com/samuel99/contentful-bug-report

Steps to Reproduce

  1. Pull content from https://github.com/samuel99/contentful-bug-report
  2. Create a contentful account with a single content type in it where the content type entry title contains an emoji.
  3. Create a content instance based on the newly created content type.
  4. Go to contentful settings and create a new delivery API key.
  5. Copy space ID and access token.
  6. Edit the gatsby-config.js spaceid and accessToken:
    {
    resolve: gatsby-source-contentful,
    options: {
    spaceId: myspaceid,
    accessToken: myContentDeliveryApiToken,
    },
    }
  7. Run npm install.
  8. Run gatsby develop

Expected Result

The plugin should remove all illegal characters before passing the content type names to GraphQL.

Actual Result

Gatsby develop fail with the message:

ERROR 

Missing onError handler for invocation 'building-schema', error was 'Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but
"Contentful✨ContactMeFormNotInBeta" does not.'. Stacktrace was 'GraphQLError: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but
"Contentful✨ContactMeFormNotInBeta" does not.
    at isValidNameError (C:\customername\node_modules\graphql\utilities\assertValidName.js:42:12)
    at assertValidName (C:\customername\node_modules\graphql\utilities\assertValidName.js:21:15)
    at checkIsAllowedTypeName (C:\customername\node_modules\gatsby\src\schema\schema.js:619:3)
    at forEach (C:\customername\node_modules\gatsby\src\schema\schema.js:297:9)
    at Array.forEach (<anonymous>)
    at addTypes (C:\customername\node_modules\gatsby\src\schema\schema.js:258:9)
    at updateSchemaComposer (C:\customername\node_modules\gatsby\src\schema\schema.js:130:9)
    at buildSchema (C:\customername\node_modules\gatsby\src\schema\schema.js:71:9)
    at build (C:\customername\node_modules\gatsby\src\schema\index.js:112:18)
    at buildSchema (C:\customername\node_modules\gatsby\src\services\build-schema.ts:19:3)'

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.13
  Browsers:
    Chrome: 102.0.5005.63
    Edge: Spartan (44.19041.1266.0), Chromium (102.0.1245.30)
  npmPackages:
    gatsby: ^4.15.2 => 4.15.2
    gatsby-plugin-image: 2.15.1 => 2.15.1
    gatsby-plugin-sharp: 4.15.1 => 4.15.1
    gatsby-source-contentful: ^7.13.1 => 7.13.1
    gatsby-source-filesystem: 4.15.0 => 4.15.0
    gatsby-transformer-sharp: 4.15.1 => 4.15.1
  npmGlobalPackages:
    gatsby-cli: 4.15.0

Config Flags

No response

@samuel99 samuel99 added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 2, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 2, 2022
@LekoArts LekoArts added topic: source-contentful Related to Gatsby's integration with Contentful topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 3, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 23, 2022
@samuel99
Copy link
Author

Hiya!

This issue has gone quiet. Spooky quiet. 👻

I kind of think this should not be closed.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 24, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jul 14, 2022
@manuelfzh
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

Please keep this issue open so it can get addressed.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Jul 20, 2022
@github-actions
Copy link

github-actions bot commented Aug 9, 2022

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Aug 9, 2022
@manuelfzh
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

Please keep this issue open so it can get addressed

@samuel99
Copy link
Author

To quote the bot, it's spooky quit from the gatsby team. Why is it automatically closed every two weeks?

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Aug 23, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Sep 12, 2022
@samuel99
Copy link
Author

I guess I'll make one last comment to keep this issue alive. But since there's no feedback whatsoever from the dev team I won't put any more energy into this.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Sep 13, 2022
@github-actions
Copy link

github-actions bot commented Oct 3, 2022

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 3, 2022
@cachrisman
Copy link

Try setting the useNameForId config option from gatsby-source-contentful to false so that it uses the content type ID from Contentful as opposed to the content type name when generating the graphql node. I believe that should fix this problem as the content type IDs from Contentful do not contain emojis

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 28, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Nov 18, 2022
@manuelfzh
Copy link

Thanks a lot @cachrisman for the hint. We tried it out and it worked!
@samuel99, I hope it solves this issue for you too.

@github-actions github-actions bot removed the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 6, 2022
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s 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.
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 for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Dec 27, 2022
@github-actions
Copy link

github-actions bot commented Feb 5, 2023

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on 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! 💪💜

@github-actions github-actions bot closed this as completed Feb 5, 2023
@atmmoreira
Copy link

Hi Folks,

I just install the Gatsby, with the Contentfull and TailwindCSS, and I'm having this issue.

Missing onError handler for invocation 'building-schema', error was 'Names must only contain [_a-zA-Z0-9] but "Contentful💎QuoteComponent" does
not.'. Stacktrace was 'GraphQLError: Names must only contain [_a-zA-Z0-9] but "Contentful💎QuoteComponent" does not.
at assertName (D:\projects\project.resume.gatsby.graphql\node_modules\graphql\type\assertName.js:31:13)
at new GraphQLObjectType (D:\projects\project.resume.gatsby.graphql\node_modules\graphql\type\definition.js:680:44)
at Function.createTemp (D:\projects\project.resume.gatsby.graphql\node_modules\graphql-compose\src\ObjectTypeComposer.ts:314:20)
at createTypeComposerFromGatsbyType (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:634:41)
at createTypeComposerFromGatsbyType (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:634:41)
at forEach (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:292:20)
at Array.forEach ()
at addTypes (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:262:9)
at updateSchemaComposer (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:134:9)
at buildSchema (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\schema.js:75:9)
at build (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\schema\index.js:141:18)
at buildSchema (D:\projects\project.resume.gatsby.graphql\node_modules\gatsby\src\services\build-schema.ts:19:3)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-contentful Related to Gatsby's integration with Contentful topic: source-plugins Relates to the Gatsby source plugins (e.g. -filesystem) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants