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

[RAV][Regression] jss graphql:update throws errors #806

Merged
merged 4 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions samples/angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions samples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@sitecore-jss/sitecore-jss-cli": "^19.0.0-canary.57",
"@sitecore-jss/sitecore-jss-dev-tools": "^19.0.0-canary.57",
"@sitecore-jss/sitecore-jss-manifest": "^19.0.0-canary.57",
"@types/isomorphic-fetch": "0.0.35",
"@types/jasmine": "~3.6.7",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~12.7.9",
Expand Down
6 changes: 3 additions & 3 deletions samples/angular/scripts/update-graphql-fragment-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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: `
{
Expand All @@ -44,10 +44,10 @@ fetch(jssConfig.graphQLEndpoint, {
`,
}),
})
.then((result: unknown) => result.json())
.then((result) => result.json())
.then((result) => {
// here we're filtering out any type information unrelated to unions or interfaces
const filteredData = result.data.__schema.types.filter((type) => type.possibleTypes !== null);
const filteredData = result.data.__schema.types.filter((type: { possibleTypes: Array<string>; }) => type.possibleTypes !== null);

const filteredResult = { ...result };
filteredResult.data.__schema.types = filteredData;
Expand Down
2 changes: 1 addition & 1 deletion samples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions samples/react/scripts/update-graphql-fragment-data.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.'
Expand All @@ -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: `
{
Expand Down
2 changes: 1 addition & 1 deletion samples/vue/scripts/update-graphql-fragment-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
{
Expand Down