Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selectionSet.selections.forEach(selection => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely
return;
}
if (isField(selection)) {
const fieldResult = handleMissing(
this.executeField(object, typename, selection, execContext),
);
if (typeof fieldResult !== 'undefined') {
objectsToMerge.push({
[resultKeyNameFromField(selection)]: fieldResult,
});
}
} else {
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
} else {
selectionSet.selections.forEach(selection => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely
return;
}
if (isField(selection)) {
const fieldResult = handleMissing(executeField(selection, rootValue, execContext));
if (typeof fieldResult !== 'undefined') {
merge(finalResult.result, {
[resultKeyNameFromField(selection)]: fieldResult,
});
}
} else {
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
} else {
// This is a named fragment
fragment = fragmentMap[selection.name.value];
const execute = async (selection: SelectionNode): Promise => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely.
return;
}
if (isField(selection)) {
return this.resolveField(selection, rootValue, execContext).then(
fieldResult => {
if (typeof fieldResult !== 'undefined') {
resultsToMerge.push({
[resultKeyNameFromField(selection)]: fieldResult,
} as TData);
}
},
);
}
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
} else {
const execute = async selection => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely
return;
}
if (isField(selection)) {
const fieldResult = await executeField(selection, rootValue, execContext);
const resultFieldKey = resultKeyNameFromField(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
} else {
merge(result[resultFieldKey], fieldResult);
}
}
return;
}
let fragment: InlineFragmentNode | FragmentDefinitionNode;
selectionSet.selections.forEach(selection => {
if (!shouldInclude(selection, variables)) {
return;
}
if (isField(selection)) {
const resultFieldKey: string = resultKeyNameFromField(selection);
const value: any = result[resultFieldKey];
if (typeof value !== 'undefined') {
this.writeFieldToStore({
dataId,
value,
field: selection,
context,
});
} else {
let isDefered = false;
let isClient = false;
if (selection.directives && selection.directives.length) {
// If this is a defered field we don't need to throw / warn.
isDefered = selection.directives.some(
selectionSet.selections.forEach(selection => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely
return;
}
if (isField(selection)) {
const fieldResult = executeField(selection, rootValue, execContext);
const resultFieldKey = resultKeyNameFromField(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
} else {
merge(result[resultFieldKey], fieldResult);
}
}
} else {
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
selectionSet.selections.forEach(selection => {
if (!shouldInclude(selection, variables)) {
// Skip this entirely
return;
}
if (isField(selection)) {
const fieldResult = executeField(selection, rootValue, execContext);
const resultFieldKey = resultKeyNameFromField(selection);
if (fieldResult !== undefined) {
if (result[resultFieldKey] === undefined) {
result[resultFieldKey] = fieldResult;
} else {
merge(result[resultFieldKey], fieldResult);
}
}
} else {
let fragment: InlineFragmentNode | FragmentDefinitionNode;
if (isInlineFragment(selection)) {
fragment = selection;
resultKey,
current,
mainDefinition,
fragmentMap,
node.selectionSet,
);
} else if (node.kind === 'FragmentSpread') {
const fragment = fragmentMap[node.name.value];
findRestDirectivesThenInsertNullsForOmittedFields(
resultKey,
current,
mainDefinition,
fragmentMap,
fragment.selectionSet,
);
} else if (isField(node)) {
const name = resultKeyNameFromField(node);
if (name === resultKey && quickFindJsonApiDirective(node)) {
// Jackpot! We found our selectionSet!
insertNullsForAnyOmittedFields(
current,
mainDefinition,
fragmentMap,
node.selectionSet,
);
} else {
findRestDirectivesThenInsertNullsForOmittedFields(
resultKey,
current,
mainDefinition,
fragmentMap,
node.selectionSet,
selectionSet.selections.forEach(function (selection) {
var included = shouldInclude(selection, variables);
if (isField(selection)) {
var resultFieldKey = resultKeyNameFromField(selection);
var value = result[resultFieldKey];
if (included) {
if (typeof value !== 'undefined') {
writeFieldToStore({
dataId: dataId,
value: value,
field: selection,
context: context,
});
}
else {
var isDefered = selection.directives &&
selection.directives.length &&
selection.directives.some(function (directive) { return directive.name && directive.name.value === 'defer'; });
if (!isDefered && context.fragmentMatcherFunction) {
const execute = async selection => {
if (isField(selection)) {
const fieldResult = await executeField(selection, rootValue, execContext)
const resultFieldKey = resultKeyNameFromField(selection)
if (fieldResult === undefined) {
return
}
return {
type: 'field',
key: resultFieldKey,
value: fieldResult
}
}
let fragment