Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.reduce((obj, x) => {
if (x.type.ofType) {
if (x.type.kind === 'LIST') {
obj[x.name] = [fakeField(x.type.ofType, typesMap)];
} else if (x.type.ofType.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type.ofType, typesMap);
} else if (['INPUT_OBJECT', 'OBJECT'].includes(x.type.ofType.kind)) {
obj[x.name] = fakeMessage(typesMap[x.type.ofType.name], typesMap);
} else {
console.log('ignoreX', x);
}
} else if (x.type.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type, typesMap);
}
return obj;
}, {});
.reduce((obj, x) => {
if (x.type.ofType) {
if (x.type.kind === 'LIST') {
obj[x.name] = [fakeField(x.type.ofType, typesMap)];
} else if (x.type.ofType.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type.ofType, typesMap);
} else if (['INPUT_OBJECT', 'OBJECT'].includes(x.type.ofType.kind)) {
obj[x.name] = fakeMessage(typesMap[x.type.ofType.name], typesMap);
} else {
console.log('ignoreX', x);
}
} else if (x.type.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type, typesMap);
}
return obj;
}, {});
.reduce((obj, x) => {
if (x.type.ofType) {
if (x.type.kind === 'LIST') {
obj[x.name] = [fakeField(x.type.ofType, typesMap)];
} else if (x.type.ofType.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type.ofType, typesMap);
} else if (['INPUT_OBJECT', 'OBJECT'].includes(x.type.ofType.kind)) {
obj[x.name] = fakeMessage(typesMap[x.type.ofType.name], typesMap);
} else {
console.log('ignoreX', x);
}
} else if (x.type.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type, typesMap);
}
return obj;
}, {});
let type = typesMap[name];
if (originName && !type) {
type =
queries.find(x => x.name === originName) ||
mutations.find(x => x.name === originName) ||
subscriptions.find(x => x.name === originName);
if (type) {
type.fields = type.args;
}
}
return `
*
* Checkout the following snippet for the format of ${name}:
* \`\`\`json
${JSON.stringify(fakeMessage(type, typesMap, 'fields'), true, ' ')}
* \`\`\``;
} catch (err) {
console.error('cannot print fake message', name);
return '';
}
};
.reduce((obj, x) => {
if (x.type.ofType) {
if (x.type.kind === 'LIST') {
obj[x.name] = [fakeField(x.type.ofType, typesMap)];
} else if (x.type.ofType.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type.ofType, typesMap);
} else if (['INPUT_OBJECT', 'OBJECT'].includes(x.type.ofType.kind)) {
obj[x.name] = fakeMessage(typesMap[x.type.ofType.name], typesMap);
} else {
console.log('ignoreX', x);
}
} else if (x.type.kind === 'SCALAR') {
obj[x.name] = fakeField(x.type, typesMap);
}
return obj;
}, {});