UNPKG

@graphql-hive/gateway-plugin-console-sdk

Version:
12 lines (11 loc) 468 B
/** * Checks if the top-level selection is an '_entities' query */ export function isEntityRequest(document) { let isEntityRequest = false; const operation = document.definitions.find(def => def.kind === 'OperationDefinition'); if (operation && operation.selectionSet) { isEntityRequest = operation.selectionSet.selections.some(selection => selection.kind === 'Field' && selection.name.value === '_entities'); } return isEntityRequest; }