@graphql-tools/utils
Advanced tools
Comparing version 10.6.0-alpha-20240813170106-2c6fb0fc8fa322bcea8c10c35972ba621a04c4a4 to 10.6.0-alpha-20241122095055-27efcb12a2a7ebe82e45e510811c27fe7dff7d95
"use strict"; | ||
// TODO: Remove this after Node 22 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -15,4 +14,4 @@ exports.createDeferred = void 0; | ||
}); | ||
return { promise, resolve: resolve, reject: reject }; | ||
return { promise, resolve, reject }; | ||
} | ||
exports.createDeferred = createDeferred; |
@@ -6,4 +6,36 @@ "use strict"; | ||
const getArgumentValues_js_1 = require("./getArgumentValues.js"); | ||
const memoize_js_1 = require("./memoize.js"); | ||
function getDirectiveExtensions(directableObj, schema, pathToDirectivesInExtensions = ['directives']) { | ||
const directiveExtensions = {}; | ||
if (directableObj.extensions) { | ||
let directivesInExtensions = directableObj.extensions; | ||
for (const pathSegment of pathToDirectivesInExtensions) { | ||
directivesInExtensions = directivesInExtensions?.[pathSegment]; | ||
} | ||
if (directivesInExtensions != null) { | ||
for (const directiveNameProp in directivesInExtensions) { | ||
const directiveObjs = directivesInExtensions[directiveNameProp]; | ||
const directiveName = directiveNameProp; | ||
if (Array.isArray(directiveObjs)) { | ||
for (const directiveObj of directiveObjs) { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObj); | ||
} | ||
} | ||
else { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObjs); | ||
} | ||
} | ||
} | ||
} | ||
const memoizedStringify = (0, memoize_js_1.memoize1)(obj => JSON.stringify(obj)); | ||
const astNodes = []; | ||
@@ -44,33 +76,9 @@ if (directableObj.astNode) { | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
} | ||
} | ||
if (directableObj.extensions) { | ||
let directivesInExtensions = directableObj.extensions; | ||
for (const pathSegment of pathToDirectivesInExtensions) { | ||
directivesInExtensions = directivesInExtensions[pathSegment]; | ||
} | ||
if (directivesInExtensions != null) { | ||
for (const directiveNameProp in directivesInExtensions) { | ||
const directiveObjs = directivesInExtensions[directiveNameProp]; | ||
const directiveName = directiveNameProp; | ||
if (Array.isArray(directiveObjs)) { | ||
for (const directiveObj of directiveObjs) { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObj); | ||
if (astNodes.length > 0 && existingDirectiveExtensions.length > 0) { | ||
const valStr = memoizedStringify(value); | ||
if (existingDirectiveExtensions.some(val => memoizedStringify(val) === valStr)) { | ||
continue; | ||
} | ||
} | ||
else { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObjs); | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
@@ -77,0 +85,0 @@ } |
@@ -63,2 +63,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./getDirectiveExtensions.js"), exports); | ||
tslib_1.__exportStar(require("./map-maybe-promise.js"), exports); | ||
tslib_1.__exportStar(require("./fakePromise.js"), exports); | ||
tslib_1.__exportStar(require("./createDeferred.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasOwnProperty = exports.promiseReduce = exports.isPromise = exports.isObjectLike = exports.isIterableObject = void 0; | ||
const map_maybe_promise_js_1 = require("./map-maybe-promise.js"); | ||
function isIterableObject(value) { | ||
@@ -19,5 +20,3 @@ return value != null && typeof value === 'object' && Symbol.iterator in value; | ||
for (const value of values) { | ||
accumulator = isPromise(accumulator) | ||
? accumulator.then(resolved => callbackFn(resolved, value)) | ||
: callbackFn(accumulator, value); | ||
accumulator = (0, map_maybe_promise_js_1.mapMaybePromise)(accumulator, resolved => callbackFn(resolved, value)); | ||
} | ||
@@ -24,0 +23,0 @@ return accumulator; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mapAsyncIterator = void 0; | ||
const jsutils_js_1 = require("./jsutils.js"); | ||
const fakePromise_js_1 = require("./fakePromise.js"); | ||
const map_maybe_promise_js_1 = require("./map-maybe-promise.js"); | ||
/** | ||
@@ -17,5 +18,6 @@ * Given an AsyncIterable and a callback function, return an AsyncIterator | ||
if (onEnd) { | ||
let onEndWithValueResult /** R in onEndWithValue */; | ||
onEndWithValue = value => { | ||
const onEnd$ = onEnd(); | ||
return (0, jsutils_js_1.isPromise)(onEnd$) ? onEnd$.then(() => value) : value; | ||
onEndWithValueResult ||= (0, map_maybe_promise_js_1.mapMaybePromise)(onEnd(), () => value); | ||
return onEndWithValueResult; | ||
}; | ||
@@ -26,3 +28,5 @@ } | ||
abruptClose = (error) => { | ||
const rethrow = () => Promise.reject(error); | ||
const rethrow = () => { | ||
throw error; | ||
}; | ||
return $return.call(iterator).then(rethrow, rethrow); | ||
@@ -35,9 +39,13 @@ }; | ||
} | ||
return asyncMapValue(result.value, onNext).then(iteratorResult, abruptClose); | ||
return (0, map_maybe_promise_js_1.mapMaybePromise)(result.value, value => (0, map_maybe_promise_js_1.mapMaybePromise)(onNext(value), iteratorResult, abruptClose)); | ||
} | ||
let mapReject; | ||
if (onError) { | ||
let onErrorResult; | ||
// Capture rejectCallback to ensure it cannot be null. | ||
const reject = onError; | ||
mapReject = (error) => asyncMapValue(error, reject).then(iteratorResult, abruptClose); | ||
mapReject = (error) => { | ||
onErrorResult ||= (0, map_maybe_promise_js_1.mapMaybePromise)(error, error => (0, map_maybe_promise_js_1.mapMaybePromise)(reject(error), iteratorResult, abruptClose)); | ||
return onErrorResult; | ||
}; | ||
} | ||
@@ -51,3 +59,3 @@ return { | ||
? $return.call(iterator).then(mapResult, mapReject) | ||
: Promise.resolve({ value: undefined, done: true }); | ||
: (0, fakePromise_js_1.fakePromise)({ value: undefined, done: true }); | ||
return onEndWithValue ? res$.then(onEndWithValue) : res$; | ||
@@ -59,3 +67,6 @@ }, | ||
} | ||
return Promise.reject(error).catch(abruptClose); | ||
if (abruptClose) { | ||
return abruptClose(error); | ||
} | ||
return (0, fakePromise_js_1.fakeRejectPromise)(error); | ||
}, | ||
@@ -68,7 +79,4 @@ [Symbol.asyncIterator]() { | ||
exports.mapAsyncIterator = mapAsyncIterator; | ||
function asyncMapValue(value, callback) { | ||
return new Promise(resolve => resolve(callback(value))); | ||
} | ||
function iteratorResult(value) { | ||
return { value, done: false }; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.memoize2of5 = exports.memoize2of4 = exports.memoize5 = exports.memoize4 = exports.memoize3of4 = exports.memoize3 = exports.memoize2 = exports.memoize1 = void 0; | ||
exports.memoize2of5 = exports.memoize2of4 = exports.memoize5 = exports.memoize4 = exports.memoize3 = exports.memoize2 = exports.memoize1 = void 0; | ||
function memoize1(fn) { | ||
@@ -69,33 +69,2 @@ const memoize1cache = new WeakMap(); | ||
exports.memoize3 = memoize3; | ||
function memoize3of4(fn) { | ||
const memoize3Cache = new WeakMap(); | ||
return function memoized(a1, a2, a3, a4) { | ||
let cache2 = memoize3Cache.get(a1); | ||
if (!cache2) { | ||
cache2 = new WeakMap(); | ||
memoize3Cache.set(a1, cache2); | ||
const cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
let cache3 = cache2.get(a2); | ||
if (!cache3) { | ||
cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
const cachedValue = cache3.get(a3); | ||
if (cachedValue === undefined) { | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
return cachedValue; | ||
}; | ||
} | ||
exports.memoize3of4 = memoize3of4; | ||
function memoize4(fn) { | ||
@@ -102,0 +71,0 @@ const memoize4Cache = new WeakMap(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeIncrementalResult = void 0; | ||
const tslib_1 = require("tslib"); | ||
const dlv_1 = tslib_1.__importDefault(require("dlv")); | ||
const merge_1 = require("dset/merge"); | ||
const pathsMap = new WeakMap(); | ||
function mergeIncrementalResult({ incrementalResult, executionResult, }) { | ||
let path = [ | ||
'data', | ||
...(incrementalResult.path ?? []), | ||
]; | ||
for (const result of [executionResult, incrementalResult]) { | ||
if (result.pending) { | ||
let paths = pathsMap.get(executionResult); | ||
if (paths === undefined) { | ||
paths = new Map(); | ||
pathsMap.set(executionResult, paths); | ||
} | ||
for (const { id, path } of result.pending) { | ||
paths.set(id, ['data', ...path]); | ||
} | ||
const path = ['data', ...(incrementalResult.path ?? [])]; | ||
if (incrementalResult.items) { | ||
for (const item of incrementalResult.items) { | ||
(0, merge_1.dset)(executionResult, path, item); | ||
// Increment the last path segment (the array index) to merge the next item at the next index | ||
path[path.length - 1]++; | ||
} | ||
} | ||
const items = incrementalResult.items; | ||
if (items) { | ||
const id = incrementalResult.id; | ||
if (id) { | ||
path = pathsMap.get(executionResult)?.get(id); | ||
if (path === undefined) { | ||
throw new Error('Invalid incremental delivery format.'); | ||
} | ||
const list = (0, dlv_1.default)(executionResult, path); | ||
list.push(...items); | ||
} | ||
else { | ||
const path = ['data', ...(incrementalResult.path ?? [])]; | ||
for (const item of items) { | ||
(0, merge_1.dset)(executionResult, path, item); | ||
// Increment the last path segment (the array index) to merge the next item at the next index | ||
path[path.length - 1]++; | ||
} | ||
} | ||
if (incrementalResult.data) { | ||
(0, merge_1.dset)(executionResult, path, incrementalResult.data); | ||
} | ||
const data = incrementalResult.data; | ||
if (data) { | ||
const id = incrementalResult.id; | ||
if (id) { | ||
path = pathsMap.get(executionResult)?.get(id); | ||
if (path === undefined) { | ||
throw new Error('Invalid incremental delivery format.'); | ||
} | ||
const subPath = incrementalResult.subPath; | ||
if (subPath !== undefined) { | ||
path = [...path, ...subPath]; | ||
} | ||
} | ||
(0, merge_1.dset)(executionResult, path, data); | ||
} | ||
if (incrementalResult.errors) { | ||
@@ -75,13 +32,3 @@ executionResult.errors = executionResult.errors || []; | ||
} | ||
if (incrementalResult.completed) { | ||
// Remove tracking and add additional errors | ||
for (const { id, errors } of incrementalResult.completed) { | ||
pathsMap.get(executionResult)?.delete(id); | ||
if (errors) { | ||
executionResult.errors = executionResult.errors || []; | ||
executionResult.errors.push(...errors); | ||
} | ||
} | ||
} | ||
} | ||
exports.mergeIncrementalResult = mergeIncrementalResult; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.observableToAsyncIterable = void 0; | ||
const fakePromise_js_1 = require("./fakePromise.js"); | ||
function observableToAsyncIterable(observable) { | ||
@@ -47,9 +48,9 @@ const pullQueue = []; | ||
next(value) { | ||
pushValue(value); | ||
return pushValue(value); | ||
}, | ||
error(err) { | ||
pushError(err); | ||
return pushError(err); | ||
}, | ||
complete() { | ||
pushDone(); | ||
return pushDone(); | ||
}, | ||
@@ -75,3 +76,3 @@ }); | ||
emptyQueue(); | ||
return Promise.resolve({ value: undefined, done: true }); | ||
return (0, fakePromise_js_1.fakePromise)({ value: undefined, done: true }); | ||
}, | ||
@@ -78,0 +79,0 @@ throw(error) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.makeDirectiveNodes = exports.makeDirectiveNode = exports.makeDeprecatedDirective = exports.astFromEnumValue = exports.astFromInputField = exports.astFromField = exports.astFromScalarType = exports.astFromEnumType = exports.astFromInputObjectType = exports.astFromUnionType = exports.astFromInterfaceType = exports.astFromObjectType = exports.astFromArg = exports.getDeprecatableDirectiveNodes = exports.getDirectiveNodes = exports.astFromDirective = exports.astFromSchema = exports.printSchemaWithDirectives = exports.getDocumentNodeFromSchema = void 0; | ||
exports.makeDirectiveNodes = exports.makeDirectiveNode = exports.makeDeprecatedDirective = exports.astFromEnumValue = exports.astFromInputField = exports.astFromField = exports.astFromScalarType = exports.astFromEnumType = exports.astFromInputObjectType = exports.astFromUnionType = exports.astFromInterfaceType = exports.astFromObjectType = exports.astFromArg = exports.getDirectiveNodes = exports.astFromDirective = exports.astFromSchema = exports.printSchemaWithDirectives = exports.getDocumentNodeFromSchema = void 0; | ||
const graphql_1 = require("graphql"); | ||
@@ -141,10 +141,4 @@ const astFromType_js_1 = require("./astFromType.js"); | ||
function getDirectiveNodes(entity, schema, pathToDirectivesInExtensions) { | ||
let directiveNodesBesidesDeprecatedAndSpecifiedBy = []; | ||
const directivesInExtensions = (0, get_directives_js_1.getDirectivesInExtensions)(entity, pathToDirectivesInExtensions); | ||
let nodes = []; | ||
if (entity.astNode != null) { | ||
nodes.push(entity.astNode); | ||
} | ||
if ('extensionASTNodes' in entity && entity.extensionASTNodes != null) { | ||
nodes = nodes.concat(entity.extensionASTNodes); | ||
} | ||
let directives; | ||
@@ -154,39 +148,33 @@ if (directivesInExtensions != null) { | ||
} | ||
else { | ||
directives = []; | ||
for (const node of nodes) { | ||
if (node.directives) { | ||
directives.push(...node.directives); | ||
} | ||
} | ||
} | ||
return directives; | ||
} | ||
exports.getDirectiveNodes = getDirectiveNodes; | ||
function getDeprecatableDirectiveNodes(entity, schema, pathToDirectivesInExtensions) { | ||
let directiveNodesBesidesDeprecated = []; | ||
let deprecatedDirectiveNode = null; | ||
const directivesInExtensions = (0, get_directives_js_1.getDirectivesInExtensions)(entity, pathToDirectivesInExtensions); | ||
let directives; | ||
if (directivesInExtensions != null) { | ||
directives = makeDirectiveNodes(schema, directivesInExtensions); | ||
} | ||
else { | ||
directives = entity.astNode?.directives; | ||
} | ||
let specifiedByDirectiveNode = null; | ||
if (directives != null) { | ||
directiveNodesBesidesDeprecated = directives.filter(directive => directive.name.value !== 'deprecated'); | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy = directives.filter(directive => directive.name.value !== 'deprecated' && directive.name.value !== 'specifiedBy'); | ||
if (entity.deprecationReason != null) { | ||
deprecatedDirectiveNode = directives.filter(directive => directive.name.value === 'deprecated')?.[0]; | ||
} | ||
if (entity.specifiedByUrl != null || entity.specifiedByURL != null) { | ||
specifiedByDirectiveNode = directives.filter(directive => directive.name.value === 'specifiedBy')?.[0]; | ||
} | ||
} | ||
if (entity.deprecationReason != null && | ||
deprecatedDirectiveNode == null) { | ||
if (entity.deprecationReason != null && deprecatedDirectiveNode == null) { | ||
deprecatedDirectiveNode = makeDeprecatedDirective(entity.deprecationReason); | ||
} | ||
return deprecatedDirectiveNode == null | ||
? directiveNodesBesidesDeprecated | ||
: [deprecatedDirectiveNode].concat(directiveNodesBesidesDeprecated); | ||
if (entity.specifiedByUrl != null || | ||
(entity.specifiedByURL != null && specifiedByDirectiveNode == null)) { | ||
const specifiedByValue = entity.specifiedByUrl || entity.specifiedByURL; | ||
const specifiedByArgs = { | ||
url: specifiedByValue, | ||
}; | ||
specifiedByDirectiveNode = makeDirectiveNode('specifiedBy', specifiedByArgs); | ||
} | ||
if (deprecatedDirectiveNode != null) { | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy.push(deprecatedDirectiveNode); | ||
} | ||
if (specifiedByDirectiveNode != null) { | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy.push(specifiedByDirectiveNode); | ||
} | ||
return directiveNodesBesidesDeprecatedAndSpecifiedBy; | ||
} | ||
exports.getDeprecatableDirectiveNodes = getDeprecatableDirectiveNodes; | ||
exports.getDirectiveNodes = getDirectiveNodes; | ||
function astFromArg(arg, schema, pathToDirectivesInExtensions) { | ||
@@ -205,3 +193,3 @@ return { | ||
: undefined, | ||
directives: getDeprecatableDirectiveNodes(arg, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(arg, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -285,5 +273,3 @@ } | ||
const directivesInExtensions = (0, get_directives_js_1.getDirectivesInExtensions)(type, pathToDirectivesInExtensions); | ||
const directives = directivesInExtensions | ||
? makeDirectiveNodes(schema, directivesInExtensions) | ||
: type.astNode?.directives || []; | ||
const directives = makeDirectiveNodes(schema, directivesInExtensions); | ||
const specifiedByValue = (type['specifiedByUrl'] || | ||
@@ -321,3 +307,3 @@ type['specifiedByURL']); | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -336,3 +322,3 @@ } | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
defaultValue: (0, astFromValue_js_1.astFromValue)(field.defaultValue, field.type) ?? undefined, | ||
@@ -350,4 +336,3 @@ }; | ||
}, | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(value, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(value, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -354,0 +339,0 @@ } |
@@ -1,2 +0,1 @@ | ||
// TODO: Remove this after Node 22 | ||
export function createDeferred() { | ||
@@ -12,3 +11,3 @@ if (Promise.withResolvers) { | ||
}); | ||
return { promise, resolve: resolve, reject: reject }; | ||
return { promise, resolve, reject }; | ||
} |
import { valueFromAST, valueFromASTUntyped } from 'graphql'; | ||
import { getArgumentValues } from './getArgumentValues.js'; | ||
import { memoize1 } from './memoize.js'; | ||
export function getDirectiveExtensions(directableObj, schema, pathToDirectivesInExtensions = ['directives']) { | ||
const directiveExtensions = {}; | ||
if (directableObj.extensions) { | ||
let directivesInExtensions = directableObj.extensions; | ||
for (const pathSegment of pathToDirectivesInExtensions) { | ||
directivesInExtensions = directivesInExtensions?.[pathSegment]; | ||
} | ||
if (directivesInExtensions != null) { | ||
for (const directiveNameProp in directivesInExtensions) { | ||
const directiveObjs = directivesInExtensions[directiveNameProp]; | ||
const directiveName = directiveNameProp; | ||
if (Array.isArray(directiveObjs)) { | ||
for (const directiveObj of directiveObjs) { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObj); | ||
} | ||
} | ||
else { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObjs); | ||
} | ||
} | ||
} | ||
} | ||
const memoizedStringify = memoize1(obj => JSON.stringify(obj)); | ||
const astNodes = []; | ||
@@ -40,33 +72,9 @@ if (directableObj.astNode) { | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
} | ||
} | ||
if (directableObj.extensions) { | ||
let directivesInExtensions = directableObj.extensions; | ||
for (const pathSegment of pathToDirectivesInExtensions) { | ||
directivesInExtensions = directivesInExtensions[pathSegment]; | ||
} | ||
if (directivesInExtensions != null) { | ||
for (const directiveNameProp in directivesInExtensions) { | ||
const directiveObjs = directivesInExtensions[directiveNameProp]; | ||
const directiveName = directiveNameProp; | ||
if (Array.isArray(directiveObjs)) { | ||
for (const directiveObj of directiveObjs) { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObj); | ||
if (astNodes.length > 0 && existingDirectiveExtensions.length > 0) { | ||
const valStr = memoizedStringify(value); | ||
if (existingDirectiveExtensions.some(val => memoizedStringify(val) === valStr)) { | ||
continue; | ||
} | ||
} | ||
else { | ||
let existingDirectiveExtensions = directiveExtensions[directiveName]; | ||
if (!existingDirectiveExtensions) { | ||
existingDirectiveExtensions = []; | ||
directiveExtensions[directiveName] = existingDirectiveExtensions; | ||
} | ||
existingDirectiveExtensions.push(directiveObjs); | ||
} | ||
existingDirectiveExtensions.push(value); | ||
} | ||
@@ -73,0 +81,0 @@ } |
@@ -58,2 +58,4 @@ export * from './loaders.js'; | ||
export * from './getDirectiveExtensions.js'; | ||
export * from './map-maybe-promise.js'; | ||
export * from './fakePromise.js'; | ||
export * from './createDeferred.js'; |
@@ -0,1 +1,2 @@ | ||
import { mapMaybePromise } from './map-maybe-promise.js'; | ||
export function isIterableObject(value) { | ||
@@ -13,5 +14,3 @@ return value != null && typeof value === 'object' && Symbol.iterator in value; | ||
for (const value of values) { | ||
accumulator = isPromise(accumulator) | ||
? accumulator.then(resolved => callbackFn(resolved, value)) | ||
: callbackFn(accumulator, value); | ||
accumulator = mapMaybePromise(accumulator, resolved => callbackFn(resolved, value)); | ||
} | ||
@@ -18,0 +17,0 @@ return accumulator; |
@@ -1,2 +0,3 @@ | ||
import { isPromise } from './jsutils.js'; | ||
import { fakePromise, fakeRejectPromise } from './fakePromise.js'; | ||
import { mapMaybePromise } from './map-maybe-promise.js'; | ||
/** | ||
@@ -14,5 +15,6 @@ * Given an AsyncIterable and a callback function, return an AsyncIterator | ||
if (onEnd) { | ||
let onEndWithValueResult /** R in onEndWithValue */; | ||
onEndWithValue = value => { | ||
const onEnd$ = onEnd(); | ||
return isPromise(onEnd$) ? onEnd$.then(() => value) : value; | ||
onEndWithValueResult ||= mapMaybePromise(onEnd(), () => value); | ||
return onEndWithValueResult; | ||
}; | ||
@@ -23,3 +25,5 @@ } | ||
abruptClose = (error) => { | ||
const rethrow = () => Promise.reject(error); | ||
const rethrow = () => { | ||
throw error; | ||
}; | ||
return $return.call(iterator).then(rethrow, rethrow); | ||
@@ -32,9 +36,13 @@ }; | ||
} | ||
return asyncMapValue(result.value, onNext).then(iteratorResult, abruptClose); | ||
return mapMaybePromise(result.value, value => mapMaybePromise(onNext(value), iteratorResult, abruptClose)); | ||
} | ||
let mapReject; | ||
if (onError) { | ||
let onErrorResult; | ||
// Capture rejectCallback to ensure it cannot be null. | ||
const reject = onError; | ||
mapReject = (error) => asyncMapValue(error, reject).then(iteratorResult, abruptClose); | ||
mapReject = (error) => { | ||
onErrorResult ||= mapMaybePromise(error, error => mapMaybePromise(reject(error), iteratorResult, abruptClose)); | ||
return onErrorResult; | ||
}; | ||
} | ||
@@ -48,3 +56,3 @@ return { | ||
? $return.call(iterator).then(mapResult, mapReject) | ||
: Promise.resolve({ value: undefined, done: true }); | ||
: fakePromise({ value: undefined, done: true }); | ||
return onEndWithValue ? res$.then(onEndWithValue) : res$; | ||
@@ -56,3 +64,6 @@ }, | ||
} | ||
return Promise.reject(error).catch(abruptClose); | ||
if (abruptClose) { | ||
return abruptClose(error); | ||
} | ||
return fakeRejectPromise(error); | ||
}, | ||
@@ -64,7 +75,4 @@ [Symbol.asyncIterator]() { | ||
} | ||
function asyncMapValue(value, callback) { | ||
return new Promise(resolve => resolve(callback(value))); | ||
} | ||
function iteratorResult(value) { | ||
return { value, done: false }; | ||
} |
@@ -63,32 +63,2 @@ export function memoize1(fn) { | ||
} | ||
export function memoize3of4(fn) { | ||
const memoize3Cache = new WeakMap(); | ||
return function memoized(a1, a2, a3, a4) { | ||
let cache2 = memoize3Cache.get(a1); | ||
if (!cache2) { | ||
cache2 = new WeakMap(); | ||
memoize3Cache.set(a1, cache2); | ||
const cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
let cache3 = cache2.get(a2); | ||
if (!cache3) { | ||
cache3 = new WeakMap(); | ||
cache2.set(a2, cache3); | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
const cachedValue = cache3.get(a3); | ||
if (cachedValue === undefined) { | ||
const newValue = fn(a1, a2, a3, a4); | ||
cache3.set(a3, newValue); | ||
return newValue; | ||
} | ||
return cachedValue; | ||
}; | ||
} | ||
export function memoize4(fn) { | ||
@@ -95,0 +65,0 @@ const memoize4Cache = new WeakMap(); |
@@ -1,56 +0,14 @@ | ||
import delve from 'dlv'; | ||
import { dset } from 'dset/merge'; | ||
const pathsMap = new WeakMap(); | ||
export function mergeIncrementalResult({ incrementalResult, executionResult, }) { | ||
let path = [ | ||
'data', | ||
...(incrementalResult.path ?? []), | ||
]; | ||
for (const result of [executionResult, incrementalResult]) { | ||
if (result.pending) { | ||
let paths = pathsMap.get(executionResult); | ||
if (paths === undefined) { | ||
paths = new Map(); | ||
pathsMap.set(executionResult, paths); | ||
} | ||
for (const { id, path } of result.pending) { | ||
paths.set(id, ['data', ...path]); | ||
} | ||
const path = ['data', ...(incrementalResult.path ?? [])]; | ||
if (incrementalResult.items) { | ||
for (const item of incrementalResult.items) { | ||
dset(executionResult, path, item); | ||
// Increment the last path segment (the array index) to merge the next item at the next index | ||
path[path.length - 1]++; | ||
} | ||
} | ||
const items = incrementalResult.items; | ||
if (items) { | ||
const id = incrementalResult.id; | ||
if (id) { | ||
path = pathsMap.get(executionResult)?.get(id); | ||
if (path === undefined) { | ||
throw new Error('Invalid incremental delivery format.'); | ||
} | ||
const list = delve(executionResult, path); | ||
list.push(...items); | ||
} | ||
else { | ||
const path = ['data', ...(incrementalResult.path ?? [])]; | ||
for (const item of items) { | ||
dset(executionResult, path, item); | ||
// Increment the last path segment (the array index) to merge the next item at the next index | ||
path[path.length - 1]++; | ||
} | ||
} | ||
if (incrementalResult.data) { | ||
dset(executionResult, path, incrementalResult.data); | ||
} | ||
const data = incrementalResult.data; | ||
if (data) { | ||
const id = incrementalResult.id; | ||
if (id) { | ||
path = pathsMap.get(executionResult)?.get(id); | ||
if (path === undefined) { | ||
throw new Error('Invalid incremental delivery format.'); | ||
} | ||
const subPath = incrementalResult.subPath; | ||
if (subPath !== undefined) { | ||
path = [...path, ...subPath]; | ||
} | ||
} | ||
dset(executionResult, path, data); | ||
} | ||
if (incrementalResult.errors) { | ||
@@ -71,12 +29,2 @@ executionResult.errors = executionResult.errors || []; | ||
} | ||
if (incrementalResult.completed) { | ||
// Remove tracking and add additional errors | ||
for (const { id, errors } of incrementalResult.completed) { | ||
pathsMap.get(executionResult)?.delete(id); | ||
if (errors) { | ||
executionResult.errors = executionResult.errors || []; | ||
executionResult.errors.push(...errors); | ||
} | ||
} | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
import { fakePromise } from './fakePromise.js'; | ||
export function observableToAsyncIterable(observable) { | ||
@@ -44,9 +45,9 @@ const pullQueue = []; | ||
next(value) { | ||
pushValue(value); | ||
return pushValue(value); | ||
}, | ||
error(err) { | ||
pushError(err); | ||
return pushError(err); | ||
}, | ||
complete() { | ||
pushDone(); | ||
return pushDone(); | ||
}, | ||
@@ -72,3 +73,3 @@ }); | ||
emptyQueue(); | ||
return Promise.resolve({ value: undefined, done: true }); | ||
return fakePromise({ value: undefined, done: true }); | ||
}, | ||
@@ -75,0 +76,0 @@ throw(error) { |
@@ -6,3 +6,3 @@ import { GraphQLDeprecatedDirective, isEnumType, isInputObjectType, isInterfaceType, isIntrospectionType, isObjectType, isScalarType, isSpecifiedDirective, isSpecifiedScalarType, isUnionType, Kind, print, } from 'graphql'; | ||
import { getDescriptionNode } from './descriptionFromObject.js'; | ||
import { getDirectivesInExtensions } from './get-directives.js'; | ||
import { getDirectivesInExtensions, } from './get-directives.js'; | ||
import { isSome } from './helpers.js'; | ||
@@ -135,10 +135,4 @@ import { getRootTypeMap } from './rootTypes.js'; | ||
export function getDirectiveNodes(entity, schema, pathToDirectivesInExtensions) { | ||
let directiveNodesBesidesDeprecatedAndSpecifiedBy = []; | ||
const directivesInExtensions = getDirectivesInExtensions(entity, pathToDirectivesInExtensions); | ||
let nodes = []; | ||
if (entity.astNode != null) { | ||
nodes.push(entity.astNode); | ||
} | ||
if ('extensionASTNodes' in entity && entity.extensionASTNodes != null) { | ||
nodes = nodes.concat(entity.extensionASTNodes); | ||
} | ||
let directives; | ||
@@ -148,36 +142,31 @@ if (directivesInExtensions != null) { | ||
} | ||
else { | ||
directives = []; | ||
for (const node of nodes) { | ||
if (node.directives) { | ||
directives.push(...node.directives); | ||
} | ||
} | ||
} | ||
return directives; | ||
} | ||
export function getDeprecatableDirectiveNodes(entity, schema, pathToDirectivesInExtensions) { | ||
let directiveNodesBesidesDeprecated = []; | ||
let deprecatedDirectiveNode = null; | ||
const directivesInExtensions = getDirectivesInExtensions(entity, pathToDirectivesInExtensions); | ||
let directives; | ||
if (directivesInExtensions != null) { | ||
directives = makeDirectiveNodes(schema, directivesInExtensions); | ||
} | ||
else { | ||
directives = entity.astNode?.directives; | ||
} | ||
let specifiedByDirectiveNode = null; | ||
if (directives != null) { | ||
directiveNodesBesidesDeprecated = directives.filter(directive => directive.name.value !== 'deprecated'); | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy = directives.filter(directive => directive.name.value !== 'deprecated' && directive.name.value !== 'specifiedBy'); | ||
if (entity.deprecationReason != null) { | ||
deprecatedDirectiveNode = directives.filter(directive => directive.name.value === 'deprecated')?.[0]; | ||
} | ||
if (entity.specifiedByUrl != null || entity.specifiedByURL != null) { | ||
specifiedByDirectiveNode = directives.filter(directive => directive.name.value === 'specifiedBy')?.[0]; | ||
} | ||
} | ||
if (entity.deprecationReason != null && | ||
deprecatedDirectiveNode == null) { | ||
if (entity.deprecationReason != null && deprecatedDirectiveNode == null) { | ||
deprecatedDirectiveNode = makeDeprecatedDirective(entity.deprecationReason); | ||
} | ||
return deprecatedDirectiveNode == null | ||
? directiveNodesBesidesDeprecated | ||
: [deprecatedDirectiveNode].concat(directiveNodesBesidesDeprecated); | ||
if (entity.specifiedByUrl != null || | ||
(entity.specifiedByURL != null && specifiedByDirectiveNode == null)) { | ||
const specifiedByValue = entity.specifiedByUrl || entity.specifiedByURL; | ||
const specifiedByArgs = { | ||
url: specifiedByValue, | ||
}; | ||
specifiedByDirectiveNode = makeDirectiveNode('specifiedBy', specifiedByArgs); | ||
} | ||
if (deprecatedDirectiveNode != null) { | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy.push(deprecatedDirectiveNode); | ||
} | ||
if (specifiedByDirectiveNode != null) { | ||
directiveNodesBesidesDeprecatedAndSpecifiedBy.push(specifiedByDirectiveNode); | ||
} | ||
return directiveNodesBesidesDeprecatedAndSpecifiedBy; | ||
} | ||
@@ -197,3 +186,3 @@ export function astFromArg(arg, schema, pathToDirectivesInExtensions) { | ||
: undefined, | ||
directives: getDeprecatableDirectiveNodes(arg, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(arg, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -271,5 +260,3 @@ } | ||
const directivesInExtensions = getDirectivesInExtensions(type, pathToDirectivesInExtensions); | ||
const directives = directivesInExtensions | ||
? makeDirectiveNodes(schema, directivesInExtensions) | ||
: type.astNode?.directives || []; | ||
const directives = makeDirectiveNodes(schema, directivesInExtensions); | ||
const specifiedByValue = (type['specifiedByUrl'] || | ||
@@ -306,3 +293,3 @@ type['specifiedByURL']); | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -320,3 +307,3 @@ } | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(field, schema, pathToDirectivesInExtensions), | ||
defaultValue: astFromValue(field.defaultValue, field.type) ?? undefined, | ||
@@ -333,4 +320,3 @@ }; | ||
}, | ||
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility | ||
directives: getDeprecatableDirectiveNodes(value, schema, pathToDirectivesInExtensions), | ||
directives: getDirectiveNodes(value, schema, pathToDirectivesInExtensions), | ||
}; | ||
@@ -337,0 +323,0 @@ } |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "10.6.0-alpha-20240813170106-2c6fb0fc8fa322bcea8c10c35972ba621a04c4a4", | ||
"version": "10.6.0-alpha-20241122095055-27efcb12a2a7ebe82e45e510811c27fe7dff7d95", | ||
"description": "Common package containing utils and types for GraphQL tools", | ||
@@ -12,3 +12,2 @@ "sideEffects": false, | ||
"cross-inspect": "1.0.1", | ||
"dlv": "^1.1.3", | ||
"dset": "^3.1.2", | ||
@@ -15,0 +14,0 @@ "tslib": "^2.4.0" |
@@ -1,2 +0,6 @@ | ||
export type Deferred<T = unknown> = PromiseWithResolvers<T>; | ||
export declare function createDeferred<T>(): Deferred<T>; | ||
export interface PromiseWithResolvers<T> { | ||
promise: Promise<T>; | ||
resolve: (value: T | PromiseLike<T>) => void; | ||
reject: (reason: any) => void; | ||
} | ||
export declare function createDeferred<T>(): PromiseWithResolvers<T>; |
@@ -1,2 +0,3 @@ | ||
import { GraphQLEnumTypeConfig, GraphQLEnumValue, GraphQLEnumValueConfig, GraphQLField, GraphQLFieldConfig, GraphQLInputField, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInterfaceTypeConfig, GraphQLNamedType, GraphQLObjectTypeConfig, GraphQLScalarTypeConfig, GraphQLSchema, GraphQLSchemaConfig, GraphQLUnionTypeConfig } from 'graphql'; | ||
import { GraphQLSchema } from 'graphql'; | ||
import { DirectableObject } from './getDirectiveExtensions.js'; | ||
export interface DirectiveAnnotation { | ||
@@ -6,3 +7,3 @@ name: string; | ||
} | ||
export type DirectableGraphQLObject = GraphQLSchema | GraphQLSchemaConfig | GraphQLNamedType | GraphQLObjectTypeConfig<any, any> | GraphQLInterfaceTypeConfig<any, any> | GraphQLUnionTypeConfig<any, any> | GraphQLScalarTypeConfig<any, any> | GraphQLEnumTypeConfig | GraphQLEnumValue | GraphQLEnumValueConfig | GraphQLInputObjectTypeConfig | GraphQLField<any, any> | GraphQLInputField | GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig; | ||
export type DirectableGraphQLObject = DirectableObject; | ||
export declare function getDirectivesInExtensions(node: DirectableGraphQLObject, pathToDirectivesInExtensions?: string[]): Array<DirectiveAnnotation>; | ||
@@ -9,0 +10,0 @@ export declare function getDirectiveInExtensions(node: DirectableGraphQLObject, directiveName: string, pathToDirectivesInExtensions?: string[]): Array<Record<string, any>> | undefined; |
import type { ASTNode, DirectiveNode, GraphQLSchema } from 'graphql'; | ||
export type DirectableASTNode = ASTNode & { | ||
directives?: readonly DirectiveNode[]; | ||
directives?: readonly DirectiveNode[] | undefined; | ||
}; | ||
export type DirectableObject = { | ||
astNode?: DirectableASTNode | null; | ||
extensionASTNodes?: readonly DirectableASTNode[] | null; | ||
astNode?: DirectableASTNode | null | undefined; | ||
extensionASTNodes?: readonly DirectableASTNode[] | null | undefined; | ||
extensions?: { | ||
directives?: Record<string, any>; | ||
} | null; | ||
directives?: Record<string, any> | undefined; | ||
} | null | undefined; | ||
}; | ||
@@ -12,0 +12,0 @@ export declare function getDirectiveExtensions<TDirectiveAnnotationsMap extends { |
@@ -13,3 +13,3 @@ import { ASTNode } from 'graphql'; | ||
export declare function isValidPath(str: any): boolean; | ||
export declare function compareStrings<A, B>(a: A, b: B): 1 | -1 | 0; | ||
export declare function compareStrings<A, B>(a: A, b: B): 0 | 1 | -1; | ||
export declare function nodeToString(a: ASTNode): string; | ||
@@ -16,0 +16,0 @@ export declare function compareNodes(a: ASTNode, b: ASTNode, customFn?: (a: any, b: any) => number): number; |
@@ -58,2 +58,4 @@ export * from './loaders.js'; | ||
export * from './getDirectiveExtensions.js'; | ||
export * from './map-maybe-promise.js'; | ||
export * from './fakePromise.js'; | ||
export * from './createDeferred.js'; |
@@ -20,12 +20,2 @@ import { DefinitionNode, DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, FieldDefinitionNode, FieldNode, FragmentDefinitionNode, GraphQLArgument, GraphQLArgumentConfig, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLEnumValueConfig, GraphQLError, GraphQLField, GraphQLFieldConfig, GraphQLInputField, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLIsTypeOfFn, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarSerializer, GraphQLScalarType, GraphQLScalarValueParser, GraphQLSchema, GraphQLType, GraphQLTypeResolver, GraphQLUnionType, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationTypeNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, SelectionNode, Source, UnionTypeDefinitionNode, UnionTypeExtensionNode } from 'graphql'; | ||
items?: TData | null; | ||
id?: string; | ||
subPath?: ReadonlyArray<string | number>; | ||
pending?: ReadonlyArray<{ | ||
id: string; | ||
path: ReadonlyArray<string | number>; | ||
}>; | ||
completed?: ReadonlyArray<{ | ||
id: string; | ||
errors?: ReadonlyArray<GraphQLError>; | ||
}>; | ||
} | ||
@@ -32,0 +22,0 @@ export interface ExecutionRequest<TVariables extends Record<string, any> = any, TContext = any, TRootValue = any, TExtensions = Record<string, any>, TReturn = any> { |
export declare function memoize1<F extends (a1: any) => any>(fn: F): F; | ||
export declare function memoize2<F extends (a1: any, a2: any) => any>(fn: F): F; | ||
export declare function memoize3<F extends (a1: any, a2: any, a3: any) => any>(fn: F): F; | ||
export declare function memoize3of4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F; | ||
export declare function memoize4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F; | ||
@@ -6,0 +5,0 @@ export declare function memoize5<F extends (a1: any, a2: any, a3: any, a4: any, a5: any) => any>(fn: F): F; |
@@ -1,3 +0,3 @@ | ||
import { DirectiveDefinitionNode, DirectiveNode, DocumentNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, FieldDefinitionNode, GraphQLArgument, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLField, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, ObjectTypeDefinitionNode, ScalarTypeDefinitionNode, SchemaDefinitionNode, SchemaExtensionNode, UnionTypeDefinitionNode } from 'graphql'; | ||
import { DirectiveAnnotation } from './get-directives.js'; | ||
import { DirectiveDefinitionNode, DirectiveNode, DocumentNode, EnumTypeDefinitionNode, EnumValueDefinitionNode, FieldDefinitionNode, GraphQLArgument, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLField, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, InputObjectTypeDefinitionNode, InputValueDefinitionNode, InterfaceTypeDefinitionNode, ObjectTypeDefinitionNode, ScalarTypeDefinitionNode, SchemaDefinitionNode, SchemaExtensionNode, UnionTypeDefinitionNode } from 'graphql'; | ||
import { DirectableGraphQLObject, DirectiveAnnotation } from './get-directives.js'; | ||
import { GetDocumentNodeFromSchemaOptions, Maybe, PrintSchemaWithDirectivesOptions } from './types.js'; | ||
@@ -8,4 +8,7 @@ export declare function getDocumentNodeFromSchema(schema: GraphQLSchema, options?: GetDocumentNodeFromSchemaOptions): DocumentNode; | ||
export declare function astFromDirective(directive: GraphQLDirective, schema?: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): DirectiveDefinitionNode; | ||
export declare function getDirectiveNodes(entity: GraphQLSchema | GraphQLNamedType | GraphQLEnumValue, schema: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): Array<DirectiveNode>; | ||
export declare function getDeprecatableDirectiveNodes(entity: GraphQLArgument | GraphQLField<any, any> | GraphQLInputField | GraphQLEnumValue, schema?: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): Array<DirectiveNode>; | ||
export declare function getDirectiveNodes<TDirectiveNode extends DirectiveNode>(entity: DirectableGraphQLObject & { | ||
deprecationReason?: string | null; | ||
specifiedByUrl?: string | null; | ||
specifiedByURL?: string | null; | ||
}, schema?: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): Array<TDirectiveNode>; | ||
export declare function astFromArg(arg: GraphQLArgument, schema?: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): InputValueDefinitionNode; | ||
@@ -21,4 +24,4 @@ export declare function astFromObjectType(type: GraphQLObjectType, schema: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): ObjectTypeDefinitionNode; | ||
export declare function astFromEnumValue(value: GraphQLEnumValue, schema: GraphQLSchema, pathToDirectivesInExtensions?: Array<string>): EnumValueDefinitionNode; | ||
export declare function makeDeprecatedDirective(deprecationReason: string): DirectiveNode; | ||
export declare function makeDirectiveNode(name: string, args?: Record<string, any>, directive?: Maybe<GraphQLDirective>): DirectiveNode; | ||
export declare function makeDirectiveNodes(schema: Maybe<GraphQLSchema>, directiveValues: DirectiveAnnotation[]): Array<DirectiveNode>; | ||
export declare function makeDeprecatedDirective<TDirectiveNode extends DirectiveNode>(deprecationReason: string): TDirectiveNode; | ||
export declare function makeDirectiveNode<TDirectiveNode extends DirectiveNode>(name: string, args?: Record<string, any>, directive?: Maybe<GraphQLDirective>): TDirectiveNode; | ||
export declare function makeDirectiveNodes<TDirectiveNode extends DirectiveNode>(schema: Maybe<GraphQLSchema>, directiveValues: DirectiveAnnotation[]): Array<TDirectiveNode>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5
258
11166
515413
- Removeddlv@^1.1.3
- Removeddlv@1.1.3(transitive)