diff --git a/samples/react/package.json b/samples/react/package.json index 46ece09ce3..07beda8ed9 100644 --- a/samples/react/package.json +++ b/samples/react/package.json @@ -108,7 +108,7 @@ "build:client:rendering-host": "cross-env-shell PUBLIC_URL=$npm_package_config_tunnelUrl \"react-scripts build\"", "build:server": "cross-env-shell NODE_ENV=production \"webpack --config server/server.webpack.config.js\"", "bootstrap": "node scripts/bootstrap.js", - "graphql:update": "node -r babel-register ./scripts/update-graphql-fragment-data.js", + "graphql:update": "node -r @babel/register ./scripts/update-graphql-fragment-data.js", "test": "react-scripts test --env=jsdom", "lint": "eslint ./src/**/*.js ./sitecore/definitions/**/*.js ./scripts/**/*.js ./server/**/*.js ./data/**/*.yml", "eject": "react-scripts eject", diff --git a/samples/react/scripts/update-graphql-fragment-data.js b/samples/react/scripts/update-graphql-fragment-data.js index 46a9b36c85..8f45194252 100644 --- a/samples/react/scripts/update-graphql-fragment-data.js +++ b/samples/react/scripts/update-graphql-fragment-data.js @@ -1,8 +1,8 @@ /* eslint-disable no-console, no-underscore-dangle */ -import fetch from 'cross-fetch'; -import fs from 'fs'; -import generateConfig from './generate-config'; +const fetch = require('cross-fetch'); +const fs = require('fs'); +const generateConfig = require('./generate-config'); // Apollo Client supports caching GraphQL responses, which can greatly reduce network traffic needs. // In order to work correctly with interfaces in GraphQL, it needs to know some basic information about @@ -17,7 +17,7 @@ let jssConfig; try { // eslint-disable-next-line global-require - jssConfig = require('../src/temp/config').default; + jssConfig = require('../src/temp/config'); } catch (e) { console.error( 'Unable to require JSS config. Ensure `jss setup` has been run, and the app has been started at least once after setup.' @@ -30,7 +30,7 @@ console.log(`Updating GraphQL fragment type data from ${jssConfig.graphQLEndpoin fetch(jssConfig.graphQLEndpoint, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', sc_apikey: jssConfig.sitecoreApiKey }, body: JSON.stringify({ query: ` {