@graphql-tools/utils
Advanced tools
Comparing version 5.0.1-alpha-d3da75f.0 to 5.0.1-alpha-d4d928c.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>]; |
@@ -1,5 +0,7 @@ | ||
import { GraphQLSchema } from 'graphql'; | ||
import { GraphQLSchema, GraphQLNamedType, GraphQLField, GraphQLInputField, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLSchemaConfig, GraphQLObjectTypeConfig, GraphQLInterfaceTypeConfig, GraphQLUnionTypeConfig, GraphQLScalarTypeConfig, GraphQLEnumTypeConfig, GraphQLInputObjectTypeConfig, GraphQLEnumValue, GraphQLEnumValueConfig } from 'graphql'; | ||
export declare type DirectiveUseMap = { | ||
[key: string]: any; | ||
}; | ||
export declare function getDirectives(schema: GraphQLSchema, node: any): DirectiveUseMap; | ||
declare 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 declare function getDirectives(schema: GraphQLSchema, node: DirectableGraphQLObject): DirectiveUseMap; | ||
export {}; |
@@ -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, GraphQLArgumentConfig, GraphQLEnumValueConfig } 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,26 +40,46 @@ 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; | ||
} | ||
export declare type SchemaTransform = (originalSchema: GraphQLSchema) => GraphQLSchema; | ||
export declare type RequestTransform = (originalRequest: Request) => Request; | ||
export declare type ResultTransform = (originalResult: ExecutionResult) => ExecutionResult; | ||
export interface Transform { | ||
transformSchema?: (originalSchema: GraphQLSchema) => GraphQLSchema; | ||
transformRequest?: (originalRequest: Request) => Request; | ||
transformResult?: (originalResult: ExecutionResult) => ExecutionResult; | ||
transformSchema?: SchemaTransform; | ||
transformRequest?: RequestTransform; | ||
transformResult?: ResultTransform; | ||
} | ||
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 = { | ||
@@ -76,32 +89,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; | ||
@@ -122,3 +155,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; | ||
@@ -179,3 +211,14 @@ 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", | ||
ARGUMENT = "MapperKind.ARGUMENT", | ||
ENUM_VALUE = "MapperKind.ENUM_VALUE" | ||
} | ||
@@ -196,2 +239,13 @@ export interface SchemaMapper { | ||
[MapperKind.SUBSCRIPTION]?: ObjectTypeMapper; | ||
[MapperKind.ENUM_VALUE]?: EnumValueMapper; | ||
[MapperKind.FIELD]?: GenericFieldMapper<GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig>; | ||
[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.ARGUMENT]?: ArgumentMapper; | ||
[MapperKind.INPUT_OBJECT_FIELD]?: InputFieldMapper; | ||
[MapperKind.DIRECTIVE]?: DirectiveMapper; | ||
@@ -202,2 +256,3 @@ } | ||
export declare type EnumTypeMapper = (type: GraphQLEnumType, schema: GraphQLSchema) => GraphQLEnumType | null | undefined; | ||
export declare type EnumValueMapper = (value: GraphQLEnumValueConfig, typeName: string, schema: GraphQLSchema) => GraphQLEnumValueConfig | [string, GraphQLEnumValueConfig] | null | undefined; | ||
export declare type CompositeTypeMapper = (type: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | null | undefined; | ||
@@ -210,1 +265,6 @@ export declare type ObjectTypeMapper = (type: GraphQLObjectType, schema: GraphQLSchema) => GraphQLObjectType | 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 ArgumentMapper = (argumentConfig: GraphQLArgumentConfig, fieldName: string, typeName: string, schema: GraphQLSchema) => GraphQLArgumentConfig | [string, GraphQLArgumentConfig] | null | undefined; | ||
export declare type InputFieldMapper = GenericFieldMapper<GraphQLInputFieldConfig>; | ||
export {}; |
{ | ||
"name": "@graphql-tools/utils", | ||
"version": "5.0.1-alpha-d3da75f.0", | ||
"version": "5.0.1-alpha-d4d928c.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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
779635
54
6950
7
0