Git Product home page Git Product logo

Comments (4)

chrbala avatar chrbala commented on June 25, 2024 1

Is there a reason why you need to publish code that uses features not supported below 14? node 12 is still in maintenance for another year.

https://nodejs.org/en/about/releases

The following does basically the same thing as the current gatsby-node.js without breaking older versions.

const write = require("write");
const path = require("path");
const { printSchema } = require("gatsby/graphql");

exports.onPostBootstrap = async ({ store }, options) => {
  try {
    const defaultLocation = path.resolve(process.cwd(), "schema.graphql");
    const defaultGetSchema = async (obj) =>
      printSchema(obj, { commentDescriptions: true });
    const defaultWriteSchema = async (location, schema) =>
      write(location, schema);

    const location = options.dest || defaultLocation;
    const { schema: internalSchemaObj } = store.getState();
    const getSchema = options.getSchema || defaultGetSchema
    let schema = (await getSchema(internalSchemaObj));
    schema = options.adjustSchema ? await options.adjustSchema(schema) : schema;

    const writeSchema = options && options.writeSchema || defaultWriteSchema;
    await writeSchema(location, schema);

    console.log("[gatsby-plugin-extract-schema] Wrote schema");
  } catch (error) {
    console.error(
      "[gatsby-plugin-extract-schema] Failed to write schema: ",
      error
    );
  }
};

from gatsby-plugin-extract-schema.

NickyMeuleman avatar NickyMeuleman commented on June 25, 2024 1

node 12 is still in maintenance for another year.

You're right :), I wanted to use those features but don't have to in this case.
The code you posted is even more readable too!
Awesome!

Do you want to create a PR with that @chrbala? Looking at it, that can be merged immediately.

from gatsby-plugin-extract-schema.

marcus13371337 avatar marcus13371337 commented on June 25, 2024 1

Thanks for the great plugin!

Encountered this problem today as well. Just to emphasize backwards compatibility, this is from gatsby docs:

Gatsby takes backwards compatibility seriously and aims to support older versions of Node.js for as long as possible. We understand that juggling different software versions is not a productive way to spend your day

from gatsby-plugin-extract-schema.

NickyMeuleman avatar NickyMeuleman commented on June 25, 2024

Hey!
Is this on a node version that's older than 14?
It's the nullish coalescing operator that was added in v14.
Later in the code, optional chaining is used too, also a v14+ feature.
https://node.green/#ES2020-features--nullish-coalescing-operator-----

from gatsby-plugin-extract-schema.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.