Comments (4)
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-plugin-extract-schema.