@graphql-tools/utils
Advanced tools
Comparing version 5.0.1-alpha-00e0ef2.0 to 5.0.1-alpha-13fb967.0
@@ -1,4 +0,3 @@ | ||
import { GraphQLFieldConfigMap, GraphQLFieldConfig } from 'graphql'; | ||
import { TypeMap } from './Interfaces'; | ||
export declare function appendFields(typeMap: TypeMap, typeName: string, fields: GraphQLFieldConfigMap<any, any>): void; | ||
export declare function removeFields(typeMap: TypeMap, typeName: string, testFn: (fieldName: string, field: GraphQLFieldConfig<any, any>) => boolean): GraphQLFieldConfigMap<any, any>; | ||
import { GraphQLFieldConfigMap, GraphQLFieldConfig, GraphQLSchema } from 'graphql'; | ||
export declare function appendObjectFields(schema: GraphQLSchema, typeName: string, additionalFields: GraphQLFieldConfigMap<any, any>): GraphQLSchema; | ||
export declare function removeObjectFields(schema: GraphQLSchema, typeName: string, testFn: (fieldName: string, field: GraphQLFieldConfig<any, any>) => boolean): [GraphQLSchema, GraphQLFieldConfigMap<any, any>]; |
@@ -7,6 +7,4 @@ import { ASTNode } from 'graphql'; | ||
export declare function isValidPath(str: string): boolean; | ||
export declare function resolveBuiltinModule<Module>(moduleName: string, option?: Module | string): Promise<Module>; | ||
export declare function resolveBuiltinModuleSync<Module>(moduleName: string, option?: Module | string): Module; | ||
export declare function compareStrings<A, B>(a: A, b: B): 0 | 1 | -1; | ||
export declare function nodeToString(a: ASTNode): string; | ||
export declare function compareNodes(a: ASTNode, b: ASTNode, customFn?: (a: any, b: any) => number): number; |
@@ -28,3 +28,4 @@ export * from './loaders'; | ||
export * from './forEachDefaultValue'; | ||
export * from './map'; | ||
export * from './mapSchema'; | ||
export * from './addTypes'; | ||
export * from './rewire'; | ||
@@ -46,1 +47,2 @@ export * from './mergeDeep'; | ||
export * from './errors'; | ||
export * from './toConfig'; |
@@ -1,2 +0,2 @@ | ||
import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType, DocumentNode, FieldNode, GraphQLEnumValue, GraphQLEnumType, GraphQLUnionType, GraphQLArgument, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, InlineFragmentNode, SelectionSetNode, GraphQLDirective, GraphQLFieldConfig, FragmentDefinitionNode, SelectionNode, VariableDefinitionNode, OperationDefinitionNode, GraphQLError, ExecutionResult as GraphQLExecutionResult } from 'graphql'; | ||
import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLScalarType, DocumentNode, FieldNode, GraphQLEnumValue, GraphQLEnumType, GraphQLUnionType, GraphQLArgument, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLDirective, FragmentDefinitionNode, SelectionNode, OperationDefinitionNode, GraphQLError, ExecutionResult as GraphQLExecutionResult, GraphQLOutputType, FieldDefinitionNode, GraphQLFieldConfig, GraphQLInputFieldConfig } from 'graphql'; | ||
import { SchemaVisitor } from './SchemaVisitor'; | ||
@@ -32,9 +32,2 @@ export interface ExecutionResult<TData = Record<string, any>> extends GraphQLExecutionResult { | ||
} | ||
export interface IAddResolveFunctionsToSchemaOptions { | ||
schema: GraphQLSchema; | ||
resolvers: IResolvers; | ||
defaultFieldResolver: IFieldResolver<any, any>; | ||
resolverValidationOptions: IResolverValidationOptions; | ||
inheritResolversFromInterfaces: boolean; | ||
} | ||
export interface IAddResolversToSchemaOptions { | ||
@@ -47,9 +40,33 @@ schema: GraphQLSchema; | ||
} | ||
export interface IResolverOptions<TSource = any, TContext = any, TArgs = any> { | ||
fragment?: string; | ||
interface ScalarTypeToResolverMap { | ||
name: '__name'; | ||
description: '__description'; | ||
serialize: '__serialize'; | ||
parseValue: '__parseValue'; | ||
parseLiteral: '__parseLiteral'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IScalarTypeResolver = GraphQLScalarType & Rename<GraphQLScalarType, ScalarTypeToResolverMap>; | ||
interface EnumTypeToResolverMap { | ||
name: '__name'; | ||
description?: '__description'; | ||
values: '__values'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IEnumTypeResolver = Record<string, any> & Rename<GraphQLEnumType, EnumTypeToResolverMap>; | ||
export interface IFieldResolverOptions<TSource = any, TContext = any, TArgs = any> { | ||
name?: string; | ||
description?: string; | ||
type?: GraphQLOutputType; | ||
args?: Array<GraphQLArgument>; | ||
resolve?: IFieldResolver<TSource, TContext, TArgs>; | ||
subscribe?: IFieldResolver<TSource, TContext, TArgs>; | ||
isDeprecated?: boolean; | ||
deprecationReason?: string; | ||
extensions?: Record<string, any>; | ||
__resolveType?: GraphQLTypeResolver<TSource, TContext>; | ||
__isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext>; | ||
astNode?: FieldDefinitionNode; | ||
} | ||
@@ -61,13 +78,6 @@ export interface Transform { | ||
} | ||
export declare type FieldTransformer = (typeName: string, fieldName: string, field: GraphQLField<any, any>) => GraphQLFieldConfig<any, any> | RenamedFieldConfig | null | undefined; | ||
export declare type RootFieldTransformer = (operation: 'Query' | 'Mutation' | 'Subscription', fieldName: string, field: GraphQLField<any, any>) => GraphQLFieldConfig<any, any> | RenamedFieldConfig | null | undefined; | ||
export declare type FieldNodeTransformer = (typeName: string, fieldName: string, fieldNode: FieldNode, fragments: Record<string, FragmentDefinitionNode>) => SelectionNode | Array<SelectionNode>; | ||
export declare type FieldNodeMapper = (fieldNode: FieldNode, fragments: Record<string, FragmentDefinitionNode>) => SelectionNode | Array<SelectionNode>; | ||
export declare type FieldNodeMappers = Record<string, Record<string, FieldNodeMapper>>; | ||
export interface RenamedFieldConfig { | ||
name: string; | ||
field?: GraphQLFieldConfig<any, any>; | ||
} | ||
export declare type FieldFilter = (typeName?: string, fieldName?: string, field?: GraphQLField<any, any>) => boolean; | ||
export declare type RootFieldFilter = (operation?: 'Query' | 'Mutation' | 'Subscription', rootFieldName?: string, field?: GraphQLField<any, any>) => boolean; | ||
export declare type FieldFilter = (typeName?: string, fieldName?: string, fieldConfig?: GraphQLFieldConfig<any, any>) => boolean; | ||
export declare type RootFieldFilter = (operation?: 'Query' | 'Mutation' | 'Subscription', rootFieldName?: string, fieldConfig?: GraphQLFieldConfig<any, any>) => boolean; | ||
export declare type RenameTypesOptions = { | ||
@@ -77,32 +87,52 @@ renameBuiltins: boolean; | ||
}; | ||
export interface ICreateRequest { | ||
sourceSchema?: GraphQLSchema; | ||
sourceParentType?: GraphQLObjectType; | ||
sourceFieldName?: string; | ||
fragments?: Record<string, FragmentDefinitionNode>; | ||
variableDefinitions?: ReadonlyArray<VariableDefinitionNode>; | ||
variableValues?: Record<string, any>; | ||
targetOperation: Operation; | ||
targetFieldName: string; | ||
selectionSet?: SelectionSetNode; | ||
fieldNodes?: ReadonlyArray<FieldNode>; | ||
} | ||
export interface ReplacementSelectionSetMapping { | ||
[typeName: string]: { | ||
[fieldName: string]: SelectionSetNode; | ||
}; | ||
} | ||
export interface ReplacementFragmentMapping { | ||
[typeName: string]: { | ||
[fieldName: string]: InlineFragmentNode; | ||
}; | ||
} | ||
export declare type IFieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TReturn; | ||
export declare type ITypedef = (() => Array<ITypedef>) | string | DocumentNode; | ||
export declare type ITypeDefinitions = ITypedef | Array<ITypedef>; | ||
export interface IResolverObject<TSource = any, TContext = any, TArgs = any> { | ||
[key: string]: IFieldResolver<TSource, TContext, TArgs> | IResolverOptions<TSource, TContext> | IResolverObject<TSource, TContext>; | ||
interface ObjectTypeToResolverMap { | ||
name: '__name'; | ||
description: '__description'; | ||
interfaces: '__interfaces'; | ||
fields: '__fields'; | ||
isTypeOf: '__isTypeOf'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IEnumResolver = Record<string, string | number>; | ||
export declare type IResolvers<TSource = any, TContext = any> = Record<string, (() => any) | IResolverObject<TSource, TContext> | IResolverOptions<TSource, TContext> | GraphQLScalarType | IEnumResolver>; | ||
export declare type IObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = { | ||
[key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>; | ||
} & Rename<GraphQLObjectType<any, any>, ObjectTypeToResolverMap>; | ||
interface InterfaceTypeToResolverMap { | ||
name: '__name'; | ||
description: '__description'; | ||
interfaces: '__interfaces'; | ||
fields: '__fields'; | ||
resolveType: '__resolveType'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IInterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = { | ||
[key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>; | ||
} & Rename<GraphQLInterfaceType, InterfaceTypeToResolverMap>; | ||
interface UnionTypeToResolverMap { | ||
name: '__name'; | ||
description: '__description'; | ||
types: '__types'; | ||
resolveType: '__resolveType'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IUnionTypeResolver = Rename<GraphQLUnionType, UnionTypeToResolverMap>; | ||
export interface InputObjectTypeToResolverMap { | ||
name: '__name'; | ||
description: '__description'; | ||
fields: '__fields'; | ||
extensions: '__extensions'; | ||
astNode: '__astNode'; | ||
extensionASTNodes: '__extensionASTNodes'; | ||
} | ||
export declare type IInputObjectTypeResolver = Rename<GraphQLInputObjectType, InputObjectTypeToResolverMap>; | ||
export declare type ISchemaLevelResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = IFieldResolver<TSource, TContext, TArgs, TReturn>; | ||
export declare type IResolvers<TSource = any, TContext = any, TArgs = Record<string, any>, TReturn = any> = Record<string, ISchemaLevelResolver<TSource, TContext, TArgs, TReturn> | IObjectTypeResolver<TSource, TContext> | IInterfaceTypeResolver<TSource, TContext> | IUnionTypeResolver | IScalarTypeResolver | IEnumTypeResolver | IInputObjectTypeResolver>; | ||
export declare type IFieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void; | ||
@@ -123,3 +153,2 @@ export declare type IDefaultValueIteratorFn = (type: GraphQLInputType, value: any) => void; | ||
} | ||
export declare type IndexedObject<V> = Record<string, V> | ReadonlyArray<V>; | ||
export declare type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLInputField | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue; | ||
@@ -180,3 +209,12 @@ export declare type VisitorSelector = (type: VisitableSchemaType, methodName: string) => Array<SchemaVisitor | SchemaVisitorMap>; | ||
SUBSCRIPTION = "MapperKind.SUBSCRIPTION", | ||
DIRECTIVE = "MapperKind.DIRECTIVE" | ||
DIRECTIVE = "MapperKind.DIRECTIVE", | ||
FIELD = "MapperKind.FIELD", | ||
COMPOSITE_FIELD = "MapperKind.COMPOSITE_FIELD", | ||
OBJECT_FIELD = "MapperKind.OBJECT_FIELD", | ||
ROOT_FIELD = "MapperKind.ROOT_FIELD", | ||
QUERY_ROOT_FIELD = "MapperKind.QUERY_ROOT_FIELD", | ||
MUTATION_ROOT_FIELD = "MapperKind.MUTATION_ROOT_FIELD", | ||
SUBSCRIPTION_ROOT_FIELD = "MapperKind.SUBSCRIPTION_ROOT_FIELD", | ||
INTERFACE_FIELD = "MapperKind.INTERFACE_FIELD", | ||
INPUT_OBJECT_FIELD = "MapperKind.INPUT_OBJECT_FIELD" | ||
} | ||
@@ -198,2 +236,10 @@ export interface SchemaMapper { | ||
[MapperKind.DIRECTIVE]?: DirectiveMapper; | ||
[MapperKind.OBJECT_FIELD]?: FieldMapper; | ||
[MapperKind.ROOT_FIELD]?: FieldMapper; | ||
[MapperKind.QUERY_ROOT_FIELD]?: FieldMapper; | ||
[MapperKind.MUTATION_ROOT_FIELD]?: FieldMapper; | ||
[MapperKind.SUBSCRIPTION_ROOT_FIELD]?: FieldMapper; | ||
[MapperKind.INTERFACE_FIELD]?: FieldMapper; | ||
[MapperKind.COMPOSITE_FIELD]?: FieldMapper; | ||
[MapperKind.INPUT_OBJECT_FIELD]?: InputFieldMapper; | ||
} | ||
@@ -210,1 +256,5 @@ export declare type NamedTypeMapper = (type: GraphQLNamedType, schema: GraphQLSchema) => GraphQLNamedType | null | undefined; | ||
export declare type DirectiveMapper = (directive: GraphQLDirective, schema: GraphQLSchema) => GraphQLDirective | null | undefined; | ||
export declare type GenericFieldMapper<F extends GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig> = (fieldConfig: F, fieldName: string, typeName: string, schema: GraphQLSchema) => F | [string, F] | null | undefined; | ||
export declare type FieldMapper = GenericFieldMapper<GraphQLFieldConfig<any, any>>; | ||
export declare type InputFieldMapper = GenericFieldMapper<GraphQLInputFieldConfig>; | ||
export {}; |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "5.0.1-alpha-00e0ef2.0", | ||
"version": "5.0.1-alpha-13fb967.0", | ||
"description": "Common package containting utils and types for GraphQL tools", | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
import { GraphQLDirective, GraphQLNamedType } from 'graphql'; | ||
import { TypeMap } from './Interfaces'; | ||
export declare function rewireTypes(originalTypeMap: Record<string, GraphQLNamedType | null>, directives: ReadonlyArray<GraphQLDirective>, options?: { | ||
skipPruning: boolean; | ||
}): { | ||
typeMap: Record<string, GraphQLNamedType>; | ||
typeMap: TypeMap; | ||
directives: Array<GraphQLDirective>; | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
749678
54
6703
7