@graphql-tools/delegate
Advanced tools
Comparing version 10.0.15 to 10.0.16-rc-20240723153759-69d33f9c6ca6f55b0be47636e2bd24aafec03c04
@@ -5,2 +5,3 @@ "use strict"; | ||
const graphql_1 = require("graphql"); | ||
const executor_1 = require("@graphql-tools/executor"); | ||
const utils_1 = require("@graphql-tools/utils"); | ||
@@ -66,2 +67,18 @@ const getDocumentMetadata_js_1 = require("./getDocumentMetadata.js"); | ||
const { usedVariables, newDocument } = finalizeGatewayDocument(targetSchema, fragments, operations); | ||
// Fail if the query is only the root __typename field | ||
if (newDocument.definitions.length === 1 && | ||
newDocument.definitions[0].kind === graphql_1.Kind.OPERATION_DEFINITION) { | ||
const operation = newDocument.definitions[0]; | ||
if (operation.selectionSet.selections.length === 1 && | ||
operation.selectionSet.selections[0].kind === graphql_1.Kind.FIELD) { | ||
const field = operation.selectionSet.selections[0]; | ||
if (field.name.value === '__typename' && operation.operation === 'query') { | ||
throw (0, utils_1.createGraphQLError)('Failed to create a gateway request. The query must contain at least one selection.', { | ||
extensions: { | ||
[executor_1.CRITICAL_ERROR]: true, | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
const newVariables = {}; | ||
@@ -258,3 +275,5 @@ if (variables != null) { | ||
if (type == null) { | ||
console.warn(`Invalid type for node: ${typeInfo.getParentType()?.name}.${node.name.value}`); | ||
// console.warn( | ||
// `Invalid type for node: ${typeInfo.getParentType()?.name}.${node.name.value}`, | ||
// ); | ||
return null; | ||
@@ -261,0 +280,0 @@ } |
import { getNamedType, versionInfo as graphqlVersionInfo, isAbstractType, isInterfaceType, isObjectType, isUnionType, Kind, TypeInfo, TypeNameMetaFieldDef, visit, visitWithTypeInfo, } from 'graphql'; | ||
import { createVariableNameGenerator, getDefinedRootType, implementsAbstractType, serializeInputValue, updateArgument, } from '@graphql-tools/utils'; | ||
import { CRITICAL_ERROR } from '@graphql-tools/executor'; | ||
import { createGraphQLError, createVariableNameGenerator, getDefinedRootType, implementsAbstractType, serializeInputValue, updateArgument, } from '@graphql-tools/utils'; | ||
import { getDocumentMetadata } from './getDocumentMetadata.js'; | ||
@@ -62,2 +63,18 @@ function finalizeGatewayDocument(targetSchema, fragments, operations) { | ||
const { usedVariables, newDocument } = finalizeGatewayDocument(targetSchema, fragments, operations); | ||
// Fail if the query is only the root __typename field | ||
if (newDocument.definitions.length === 1 && | ||
newDocument.definitions[0].kind === Kind.OPERATION_DEFINITION) { | ||
const operation = newDocument.definitions[0]; | ||
if (operation.selectionSet.selections.length === 1 && | ||
operation.selectionSet.selections[0].kind === Kind.FIELD) { | ||
const field = operation.selectionSet.selections[0]; | ||
if (field.name.value === '__typename' && operation.operation === 'query') { | ||
throw createGraphQLError('Failed to create a gateway request. The query must contain at least one selection.', { | ||
extensions: { | ||
[CRITICAL_ERROR]: true, | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
const newVariables = {}; | ||
@@ -253,3 +270,5 @@ if (variables != null) { | ||
if (type == null) { | ||
console.warn(`Invalid type for node: ${typeInfo.getParentType()?.name}.${node.name.value}`); | ||
// console.warn( | ||
// `Invalid type for node: ${typeInfo.getParentType()?.name}.${node.name.value}`, | ||
// ); | ||
return null; | ||
@@ -256,0 +275,0 @@ } |
{ | ||
"name": "@graphql-tools/delegate", | ||
"version": "10.0.15", | ||
"version": "10.0.16-rc-20240723153759-69d33f9c6ca6f55b0be47636e2bd24aafec03c04", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -11,3 +11,3 @@ "sideEffects": false, | ||
"@graphql-tools/batch-execute": "^9.0.4", | ||
"@graphql-tools/executor": "^1.2.8", | ||
"@graphql-tools/executor": "1.3.0-rc-20240723153759-69d33f9c6ca6f55b0be47636e2bd24aafec03c04", | ||
"@graphql-tools/schema": "^10.0.4", | ||
@@ -14,0 +14,0 @@ "@graphql-tools/utils": "^10.2.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222142
4361
2