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

printTypeDefinitions throws TypeError: flatMap is not a function #19191

Closed
m4rrc0 opened this issue Oct 31, 2019 · 4 comments
Closed

printTypeDefinitions throws TypeError: flatMap is not a function #19191

m4rrc0 opened this issue Oct 31, 2019 · 4 comments
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby

Comments

@m4rrc0
Copy link
Contributor

m4rrc0 commented Oct 31, 2019

Edit: I found the bug. See second comment.

Description

I am trying to use gatsby-plugin-schema-snapshot and it throws TypeError: flatMap is not a function.
This throws as well:

exports.createSchemaCustomization = ({ actions }) => {
  actions.printTypeDefinitions({});
};

Steps to reproduce

  1. Create a new project.
  2. Add gatsby-plugin-schema-snapshot to the project or the above mentioned snippet in gatsby-node.js
  3. gatsby develop or gatsby build

Demo repo
Full log on Netlify

I was initially on NodeJS 10 (like Netlify is on the build above). I tried upgrading to Node 13 in case the polyfill was causing the problem but no luck.

Expected result

Should produce a schema.gql file

Actual result

TypeError: flatMap is not a function
See full log on Netlify

Environment

  System:
    OS: Linux 4.19 Debian GNU/Linux 9 (stretch) 9 (stretch)
    CPU: (8) x64 06/8e
    Shell: 5.3.1 - /usr/bin/zsh
  Binaries:
    Node: 13.0.1 - /usr/bin/node
    Yarn: 1.19.1 - /usr/bin/yarn
    npm: 6.12.0 - /usr/bin/npm
  Languages:
    Python: 2.7.13 - /usr/bin/python
  Browsers:
    Firefox: 60.9.0
  npmPackages:
    gatsby: ^2.17.6 => 2.17.6
    gatsby-image: ^2.2.30 => 2.2.30
    gatsby-plugin-manifest: ^2.2.25 => 2.2.25
    gatsby-plugin-offline: ^3.0.17 => 3.0.17
    gatsby-plugin-react-helmet: ^3.1.13 => 3.1.13
    gatsby-plugin-schema-snapshot: ^1.0.0 => 1.0.0
    gatsby-plugin-sharp: ^2.2.34 => 2.2.34
    gatsby-source-filesystem: ^2.1.35 => 2.1.35
    gatsby-transformer-sharp: ^2.3.1 => 2.3.1
@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Oct 31, 2019

What is strange is that I tried the snippet I mention a couple months back and all was working fine. I tried downgrading the gatsby package to the version I used back then but it didn't work either. Maybe a dependency changed...?

@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Oct 31, 2019

Oh I've found the bug:
flatMap is indeed a function
It is a default export.
In gatsby, it is not imported as default

FIX:

- const { flatMap } = require(`graphql/polyfills/flatMap`)

+ const flatMap = require(`graphql/polyfills/flatMap`).default

I don't have time for a PR right now, sorry... =/

@LekoArts LekoArts added help wanted Issue with a clear description that the community can help with. status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby labels Nov 1, 2019
@m4rrc0
Copy link
Contributor Author

m4rrc0 commented Nov 1, 2019

Such a simple PR... (#19208) I tried creating it from Github UI directly.
Please tell me if it is ok. I know I am supposed to fork and so on but this makes the process so much easier.

@thecodingaviator thecodingaviator removed the help wanted Issue with a clear description that the community can help with. label Nov 1, 2019
@stefanprobst
Copy link
Contributor

should be fixed by #19208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: confirmed Issue with steps to reproduce the bug that’s been verified by at least one reviewer. type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants