Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nexus

Package Overview
Dependencies
Maintainers
4
Versions
395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus - npm Package Compare versions

Comparing version 1.4.0-next.6 to 1.4.0-next.7

dist-esm/definitions/directive.d.ts

39

dist-esm/builder.d.ts

@@ -1,2 +0,2 @@

import { GraphQLNamedType, GraphQLSchema, GraphQLSchemaConfig, printSchema } from 'graphql';
import { ASTKindToNode, GraphQLDirective, GraphQLNamedType, GraphQLSchema, GraphQLSchemaConfig, printSchema } from 'graphql';
import { InputDefinitionBlock } from './definitions/definitionBlocks';

@@ -8,3 +8,3 @@ import type { NexusExtendInputTypeDef } from './definitions/extendInputType';

import { AllNexusNamedTypeDefs, AllNexusOutputTypeDefs } from './definitions/wrapping';
import type { MissingType, NexusFeaturesInput, NexusGraphQLSchema, NonNullConfig, TypingImport } from './definitions/_types';
import type { MissingType, NexusFeaturesInput, NonNullConfig, TypingImport } from './definitions/_types';
import type { DynamicInputMethodDef, DynamicOutputMethodDef } from './dynamicMethod';

@@ -19,2 +19,3 @@ import type { DynamicOutputPropertyDef } from './dynamicProperty';

import { NexusMeta } from './definitions/nexusMeta';
import { Directives, NexusDirectiveConfig, NexusDirectiveDef } from './definitions/directive';
declare type NexusShapedOutput = {

@@ -185,2 +186,9 @@ name: string;

plugins: RequiredDeeply<BuilderConfigInput['plugins']>;
/**
* A list of directives / directive uses (with args) for the schema definition
*
* @example
* schemaDirectives: [addDirective('ExampleDirective', { arg: true })]
*/
schemaDirectives?: Directives;
}

@@ -245,2 +253,5 @@ /**

value: NexusInterfaceTypeConfig<any>;
} | {
type: 'directive';
value: NexusDirectiveConfig;
};

@@ -252,3 +263,3 @@ export declare type DynamicInputFields = Record<string, DynamicInputMethodDef<string> | string>;

export declare type DynamicBlockDef = DynamicInputMethodDef<string> | DynamicOutputMethodDef<string> | DynamicOutputPropertyDef<string>;
export declare type NexusAcceptedTypeDef = TypeDef | DynamicBlockDef | NexusMeta;
export declare type NexusAcceptedTypeDef = TypeDef | DynamicBlockDef | NexusMeta | NexusDirectiveDef | GraphQLDirective;
export declare type PluginBuilderLens = {

@@ -302,2 +313,9 @@ hasType: SchemaBuilder['hasType'];

private plugins;
/** All GraphQL Directives */
private directivesMap;
/** All Directives that are defined */
private pendingDirectives;
/** All Schema Directives */
/** Whether we have used any custom directives within the schema construction */
private hasSDLDirectives;
/** All types that need to be traversed for children types */

@@ -361,2 +379,5 @@ private typesToWalk;

private addInputField;
private addDirective;
private buildDirective;
private maybeAddDirectiveUses;
private buildEnumType;

@@ -382,2 +403,3 @@ private buildUnionType;

private getOrBuildType;
private walkDirectiveDef;
private walkInputType;

@@ -413,10 +435,9 @@ private addDynamicInputFields;

onAfterBuildFns: SchemaBuilder['onAfterBuildFns'];
customDirectives: Record<string, GraphQLDirective>;
hasSDLDirectives: boolean;
schemaDirectives?: Partial<{
astNode: ASTKindToNode['SchemaDefinition'];
}>;
}
/** Builds the schema, we may return more than just the schema from this one day. */
export declare function makeSchemaInternal(config: SchemaConfig): {
schema: NexusGraphQLSchema;
missingTypes: Record<string, MissingType>;
finalConfig: BuilderConfig;
};
export declare function setConfigDefaults(config: BuilderConfigInput): BuilderConfig;
export {};
import { __rest } from "tslib";
import { assertValidName, defaultFieldResolver, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, isInputObjectType, isInputType, isInterfaceType, isLeafType, isNamedType, isObjectType, isOutputType, isSchema, isWrappingType, } from 'graphql';
import { assertValidName, defaultFieldResolver, GraphQLBoolean, GraphQLDirective, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLString, GraphQLUnionType, isDirective, isInputObjectType, isInputType, isInterfaceType, isLeafType, isNamedType, isObjectType, isOutputType, isSchema, isWrappingType, } from 'graphql';
import { InputDefinitionBlock, } from './definitions/definitionBlocks';

@@ -7,3 +7,3 @@ import { InterfaceDefinitionBlock, } from './definitions/interfaceType';

import { UnionDefinitionBlock } from './definitions/unionType';
import { finalizeWrapping, isNexusDynamicInputMethod, isNexusDynamicOutputMethod, isNexusDynamicOutputProperty, isNexusEnumTypeDef, isNexusExtendInputTypeDef, isNexusExtendTypeDef, isNexusInputObjectTypeDef, isNexusInterfaceTypeDef, isNexusNamedInputTypeDef, isNexusNamedOuputTypeDef, isNexusNamedTypeDef, isNexusObjectTypeDef, isNexusPlugin, isNexusScalarTypeDef, isNexusUnionTypeDef, isNexusWrappingType, normalizeArgWrapping, rewrapAsGraphQLType, unwrapGraphQLDef, unwrapNexusDef, } from './definitions/wrapping';
import { finalizeWrapping, isNexusDirective, isNexusDirectiveUse, isNexusDynamicInputMethod, isNexusDynamicOutputMethod, isNexusDynamicOutputProperty, isNexusEnumTypeDef, isNexusExtendInputTypeDef, isNexusExtendTypeDef, isNexusInputObjectTypeDef, isNexusInterfaceTypeDef, isNexusNamedInputTypeDef, isNexusNamedOuputTypeDef, isNexusNamedTypeDef, isNexusObjectTypeDef, isNexusPlugin, isNexusScalarTypeDef, isNexusUnionTypeDef, isNexusWrappingType, normalizeArgWrapping, rewrapAsGraphQLType, unwrapGraphQLDef, unwrapNexusDef, } from './definitions/wrapping';
import { hasNexusExtension, NexusFieldExtension, NexusInputObjectTypeExtension, NexusInterfaceTypeExtension, NexusObjectTypeExtension, NexusSchemaExtension, } from './extensions';

@@ -14,4 +14,5 @@ import { messages } from './messages';

import { fieldAuthorizePlugin } from './plugins/fieldAuthorizePlugin';
import { casesHandled, consoleWarn, eachObj, getArgNamedType, getNexusNamedType, graphql15InterfaceType, invariantGuard, isArray, isObject, objValues, UNKNOWN_TYPE_SCALAR, } from './utils';
import { casesHandled, consoleWarn, eachObj, getArgNamedType, getNexusNamedType, graphql15InterfaceType, invariantGuard, isArray, isObject, UNKNOWN_TYPE_SCALAR, } from './utils';
import { NEXUS_BUILD, isNexusMetaBuild, isNexusMeta, isNexusMetaType, resolveNexusMetaType, } from './definitions/nexusMeta';
import { maybeAddDirectiveUses, } from './definitions/directive';
import { rebuildNamedType } from './rebuildType';

@@ -67,2 +68,10 @@ const SCALARS = {

this.plugins = [];
/** All GraphQL Directives */
this.directivesMap = {};
/** All Directives that are defined */
this.pendingDirectives = {};
/** All Schema Directives */
// private schemaDirectives: GraphQLDirective[] = []
/** Whether we have used any custom directives within the schema construction */
this.hasSDLDirectives = false;
/** All types that need to be traversed for children types */

@@ -128,2 +137,11 @@ this.typesToWalk = [];

}
if (isNexusDirective(typeDef)) {
this.typesToWalk.push({ type: 'directive', value: typeDef.value });
const existingDirective = this.pendingDirectives[typeDef.value.name];
if (existingDirective && existingDirective !== typeDef.value) {
console.error(new Error(`Already have a directive named ${typeDef.value.name}`));
}
this.pendingDirectives[typeDef.value.name] = typeDef.value;
return;
}
if (isNexusMeta(typeDef)) {

@@ -172,2 +190,6 @@ this.addToNexusMeta(typeDef);

}
if (isDirective(typeDef)) {
this.addDirective(typeDef);
return;
}
// If it's a concrete GraphQL type, we handle it directly by convering the

@@ -260,2 +282,3 @@ // type to a Nexus structure, and capturing all of the referenced types

this.addTypes(types.getTypeMap());
this.addTypes(types.getDirectives());
}

@@ -274,2 +297,4 @@ return;

isNamedType(types) ||
isDirective(types) ||
isNexusDirective(types) ||
isNexusDynamicInputMethod(types) ||

@@ -314,2 +339,5 @@ isNexusDynamicOutputMethod(types) ||

break;
case 'directive':
this.walkDirectiveDef(obj.value);
break;
default:

@@ -421,2 +449,6 @@ casesHandled(obj);

}
Object.keys(this.pendingDirectives).forEach((key) => {
const directiveDef = this.pendingDirectives[key];
this.directivesMap[directiveDef.name] = this.buildDirective(directiveDef);
});
Object.keys(this.pendingTypeMap).forEach((key) => {

@@ -476,2 +508,5 @@ if (this.typesToWalk.length > 0) {

onAfterBuildFns: this.onAfterBuildFns,
customDirectives: this.directivesMap,
hasSDLDirectives: this.hasSDLDirectives,
schemaDirectives: this.maybeAddDirectiveUses('SCHEMA', this.config.schemaDirectives),
};

@@ -509,8 +544,3 @@ }

this.inputTypeExtendMap[config.name] = null;
const inputObjectTypeConfig = {
name: config.name,
fields: () => this.buildInputObjectFields(fields, inputObjectTypeConfig),
description: config.description,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusInputObjectTypeExtension(config) }),
};
const inputObjectTypeConfig = Object.assign({ name: config.name, fields: () => this.buildInputObjectFields(fields, inputObjectTypeConfig), description: config.description, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusInputObjectTypeExtension(config) }) }, this.maybeAddDirectiveUses('INPUT_OBJECT', config.directives));
return this.finalize(new GraphQLInputObjectType(inputObjectTypeConfig));

@@ -548,10 +578,3 @@ }

}
const objectTypeConfig = {
name: config.name,
interfaces: () => this.buildInterfaceList(interfaces),
description: config.description,
fields: () => this.buildOutputFields(fields, objectTypeConfig, this.buildInterfaceFields(objectTypeConfig, interfaces, modifications)),
isTypeOf: config.isTypeOf,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusObjectTypeExtension(config) }),
};
const objectTypeConfig = Object.assign({ name: config.name, interfaces: () => this.buildInterfaceList(interfaces), description: config.description, fields: () => this.buildOutputFields(fields, objectTypeConfig, this.buildInterfaceFields(objectTypeConfig, interfaces, modifications)), isTypeOf: config.isTypeOf, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusObjectTypeExtension(config) }) }, this.maybeAddDirectiveUses('OBJECT', config.directives));
return this.finalize(new GraphQLObjectType(objectTypeConfig));

@@ -581,10 +604,4 @@ }

}
const interfaceTypeConfig = {
name,
interfaces: () => this.buildInterfaceList(interfaces),
resolveType,
description,
fields: () => this.buildOutputFields(fields, interfaceTypeConfig, this.buildInterfaceFields(interfaceTypeConfig, interfaces, modifications)),
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusInterfaceTypeExtension(config) }),
};
const interfaceTypeConfig = Object.assign({ name, interfaces: () => this.buildInterfaceList(interfaces), resolveType,
description, fields: () => this.buildOutputFields(fields, interfaceTypeConfig, this.buildInterfaceFields(interfaceTypeConfig, interfaces, modifications)), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new NexusInterfaceTypeExtension(config) }) }, this.maybeAddDirectiveUses('INTERFACE', config.directives));
return this.finalize(new GraphQLInterfaceType(interfaceTypeConfig));

@@ -610,2 +627,38 @@ }

}
addDirective(kind) {
if (isNexusDirectiveUse(kind)) {
if (kind.config && !this.pendingDirectives[kind.name]) {
this.directivesMap[kind.name] = this.buildDirective(kind.config);
}
}
else if (isDirective(kind)) {
this.directivesMap[kind.name] = kind;
}
else if (isNexusDirective(kind)) {
this.directivesMap[kind.value.name] = this.buildDirective(kind.value);
}
}
buildDirective(config) {
return new GraphQLDirective({
name: config.name,
args: config.args ? this.buildArgs(config.args, config, 'directive') : undefined,
locations: config.locations,
isRepeatable: config.isRepeatable,
extensions: config.extensions,
description: config.description,
});
}
maybeAddDirectiveUses(kind, directives) {
if (!directives) {
return;
}
for (const directive of directives) {
this.addDirective(directive);
}
const result = maybeAddDirectiveUses(kind, directives, this.directivesMap);
if (result) {
this.hasSDLDirectives = true;
}
return result;
}
buildEnumType(config) {

@@ -652,8 +705,3 @@ var _a, _b;

}
return this.finalize(new GraphQLEnumType({
name: config.name,
values: values,
description: config.description,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }),
}));
return this.finalize(new GraphQLEnumType(Object.assign({ name: config.name, values: values, description: config.description, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }, this.maybeAddDirectiveUses('ENUM', config.directives))));
}

@@ -671,9 +719,3 @@ buildUnionType(config) {

}
return this.finalize(new GraphQLUnionType({
name: config.name,
resolveType,
description: config.description,
types: () => this.buildUnionMembers(config.name, members),
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }),
}));
return this.finalize(new GraphQLUnionType(Object.assign({ name: config.name, resolveType, description: config.description, types: () => this.buildUnionMembers(config.name, members), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }, this.maybeAddDirectiveUses('UNION', config.directives))));
}

@@ -685,3 +727,3 @@ buildScalarType(config) {

}
return this.finalize(new GraphQLScalarType(Object.assign(Object.assign({}, config), { extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) })));
return this.finalize(new GraphQLScalarType(Object.assign(Object.assign(Object.assign({}, config), { extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }), this.maybeAddDirectiveUses('SCALAR', config.directives))));
}

@@ -810,10 +852,3 @@ finalize(type) {

const finalWrap = finalizeWrapping(nonNullDefault, wrapping, fieldConfig.wrapping);
const builderFieldConfig = {
name: fieldConfig.name,
type: rewrapAsGraphQLType(this.getOutputType(namedType), finalWrap),
args: this.buildArgs(fieldConfig.args || {}, typeConfig, fieldConfig.name),
description: fieldConfig.description,
deprecationReason: fieldConfig.deprecation,
extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: fieldExtension }),
};
const builderFieldConfig = Object.assign({ name: fieldConfig.name, type: rewrapAsGraphQLType(this.getOutputType(namedType), finalWrap), args: this.buildArgs(fieldConfig.args || {}, typeConfig, fieldConfig.name), description: fieldConfig.description, deprecationReason: fieldConfig.deprecation, extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: fieldExtension }) }, this.maybeAddDirectiveUses('FIELD_DEFINITION', fieldConfig.directives));
return Object.assign({ resolve: this.makeFinalResolver({

@@ -842,8 +877,3 @@ builder: this.builderLens,

const finalWrap = finalizeWrapping(nonNullDefault, wrapping, fieldConfig.wrapping);
return {
type: rewrapAsGraphQLType(this.getInputType(namedType), finalWrap),
defaultValue: fieldConfig.default,
description: fieldConfig.description,
extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: (_d = (_c = fieldConfig.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }),
};
return Object.assign({ type: rewrapAsGraphQLType(this.getInputType(namedType), finalWrap), defaultValue: fieldConfig.default, description: fieldConfig.description, extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: (_d = (_c = fieldConfig.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }) }, this.maybeAddDirectiveUses('INPUT_FIELD_DEFINITION', fieldConfig.directives));
}

@@ -865,8 +895,3 @@ buildArgs(args, typeConfig, fieldName) {

const finalWrap = finalizeWrapping(nonNullDefault, wrapping);
allArgs[argName] = {
type: rewrapAsGraphQLType(this.getInputType(namedType), finalWrap),
description: finalArgDef.description,
defaultValue: finalArgDef.default,
extensions: Object.assign(Object.assign({}, finalArgDef.extensions), { nexus: (_d = (_c = finalArgDef.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }),
};
allArgs[argName] = Object.assign({ type: rewrapAsGraphQLType(this.getInputType(namedType), finalWrap), description: finalArgDef.description, defaultValue: finalArgDef.default, extensions: Object.assign(Object.assign({}, finalArgDef.extensions), { nexus: (_d = (_c = finalArgDef.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }) }, this.maybeAddDirectiveUses('ARGUMENT_DEFINITION', finalArgDef.directives));
}

@@ -957,2 +982,7 @@ return allArgs;

}
walkDirectiveDef(def) {
if (def.args) {
this.traverseArgs(def.args);
}
}
walkInputType(obj) {

@@ -1114,4 +1144,7 @@ const definitionBlock = new InputDefinitionBlock({

var _a;
const { types } = config.schema.toConfig();
const { types, directives } = config.schema.toConfig();
const mergedTypes = {};
for (const directive of directives) {
this.addDirective(directive);
}
// We don't need to worry about capturing any types while walking,

@@ -1143,38 +1176,2 @@ // because we have the entire schema

}
/** Builds the schema, we may return more than just the schema from this one day. */
export function makeSchemaInternal(config) {
const builder = new SchemaBuilder(config);
builder.addTypes(config.types);
if (config.schemaRoots) {
builder.addTypes(config.schemaRoots);
}
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns } = builder.getFinalTypeMap();
function getRootType(rootType, defaultType) {
var _a, _b;
const rootTypeVal = (_b = (_a = config.schemaRoots) === null || _a === void 0 ? void 0 : _a[rootType]) !== null && _b !== void 0 ? _b : defaultType;
let returnVal = null;
if (typeof rootTypeVal === 'string') {
returnVal = typeMap[rootTypeVal];
}
else if (rootTypeVal) {
if (isNexusObjectTypeDef(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
else if (isObjectType(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
}
if (returnVal && !isObjectType(returnVal)) {
throw new Error(`Expected ${rootType} to be a objectType, saw ${returnVal.constructor.name}`);
}
return returnVal;
}
const schema = new GraphQLSchema(Object.assign(Object.assign({}, extractGraphQLSchemaOptions(config)), { query: getRootType('query', 'Query'), mutation: getRootType('mutation', 'Mutation'), subscription: getRootType('subscription', 'Subscription'), types: objValues(typeMap), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: schemaExtension }) }));
onAfterBuildFns.forEach((fn) => fn(schema));
return { schema, missingTypes, finalConfig };
}
function extractGraphQLSchemaOptions(config) {
const { formatTypegen, nonNullDefaults, mergeSchema, outputs, shouldExitAfterGenerateArtifacts, shouldGenerateArtifacts, schemaRoots, sourceTypes, prettierConfig, plugins, customPrintSchemaFn, features, contextType } = config, graphqlConfigOpts = __rest(config, ["formatTypegen", "nonNullDefaults", "mergeSchema", "outputs", "shouldExitAfterGenerateArtifacts", "shouldGenerateArtifacts", "schemaRoots", "sourceTypes", "prettierConfig", "plugins", "customPrintSchemaFn", "features", "contextType"]);
return graphqlConfigOpts;
}
export function setConfigDefaults(config) {

@@ -1181,0 +1178,0 @@ var _a, _b, _c, _d, _e;

export * from './builder';
export * from './makeSchema';
export * from './definitions/args';
export * from './definitions/directive';
export * from './definitions/decorateType';

@@ -5,0 +6,0 @@ export * from './definitions/definitionBlocks';

@@ -6,2 +6,3 @@ // The "core" is used as a namespace to re-export everything,

export * from './definitions/args';
export * from './definitions/directive';
export * from './definitions/decorateType';

@@ -8,0 +9,0 @@ export * from './definitions/definitionBlocks';

import type { GraphQLCompositeType, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLInputObjectTypeConfig, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLLeafType, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLScalarType, GraphQLSchema, GraphQLUnionType } from 'graphql';
import type { NexusDirectiveConfig } from '../core';
import type { NexusFieldExtension, NexusInputObjectTypeExtension, NexusInterfaceTypeExtension, NexusObjectTypeExtension, NexusSchemaExtension } from '../extensions';

@@ -30,3 +31,5 @@ import type * as AbstractTypes from '../typegenAbstractTypes';

Scalar = "Scalar",
Union = "Union"
Union = "Union",
Directive = "Directive",
DirectiveUse = "DirectiveUse"
}

@@ -105,2 +108,3 @@ export interface DeprecationInfo {

};
export declare type NexusGraphQLDirectiveConfig = WithExt<NexusDirectiveConfig, NexusInputObjectTypeExtension>;
export interface NexusGraphQLSchema extends GraphQLSchema {

@@ -107,0 +111,0 @@ extensions: {

@@ -23,2 +23,4 @@ export var NexusTypes;

NexusTypes["Union"] = "Union";
NexusTypes["Directive"] = "Directive";
NexusTypes["DirectiveUse"] = "DirectiveUse";
})(NexusTypes || (NexusTypes = {}));

@@ -25,0 +27,0 @@ export const NexusWrappedSymbol = Symbol.for('@nexus/wrapped');

import type { GraphQLScalarTypeConfig } from 'graphql';
import type { AllInputTypes, GetGen2 } from '../typegenTypeHelpers';
import type { Directives } from './directive';
import type { AllNexusArgsDefs, AllNexusInputTypeDefs } from './wrapping';

@@ -47,2 +48,9 @@ import { Maybe } from './_types';

extensions?: GraphQLScalarTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the arg definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginArgConfig;

@@ -49,0 +57,0 @@ export interface ScalarArgConfig<T> extends CommonArgConfig {

import type { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLInputFieldConfig } from 'graphql';
import type { AllInputTypes, FieldResolver, GetGen, GetGen3, HasGen3, NeedsResolver } from '../typegenTypeHelpers';
import type { ArgsRecord } from './args';
import type { Directives } from './directive';
import type { NexusMetaType } from './nexusMeta';

@@ -96,2 +97,9 @@ import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping';

extensions?: GraphQLFieldConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginFieldConfig<TypeName, FieldName>;

@@ -107,2 +115,9 @@ export declare type CommonInputFieldConfig<TypeName extends string, FieldName extends string> = CommonFieldConfig & {

extensions?: GraphQLInputFieldConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the input field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginFieldConfig<TypeName, FieldName> & NexusGenPluginInputFieldConfig<TypeName, FieldName>;

@@ -109,0 +124,0 @@ export interface OutputScalarConfig<TypeName extends string, FieldName extends string> extends CommonOutputFieldConfig<TypeName, FieldName> {

import { GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql';
import { NexusArgDef, NexusAsArgConfig } from './args';
import type { Directives } from './directive';
import { Maybe, SourceTypingDef } from './_types';

@@ -25,2 +26,9 @@ declare type TypeScriptEnumLike = {

extensions?: GraphQLEnumValueConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the enum member definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
}

@@ -41,2 +49,9 @@ export interface NexusEnumTypeConfig<TypeName extends string> {

extensions?: GraphQLEnumTypeConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the enum type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -43,0 +58,0 @@ asNexusMethod?: string;

import { GraphQLInputObjectTypeConfig } from 'graphql';
import { NexusArgDef, NexusAsArgConfig } from './args';
import type { InputDefinitionBlock } from './definitionBlocks';
import type { Directives } from './directive';
import { Maybe, NonNullConfig } from './_types';

@@ -23,2 +24,9 @@ export declare type NexusInputObjectTypeConfig<TypeName extends string> = {

extensions?: GraphQLInputObjectTypeConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the input object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -25,0 +33,0 @@ asNexusMethod?: string;

@@ -5,2 +5,3 @@ import { GraphQLInterfaceTypeConfig } from 'graphql';

import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks';
import type { Directives } from './directive';
import { AbstractTypes, Maybe, NonNullConfig, SourceTypingDef } from './_types';

@@ -44,2 +45,9 @@ export declare type Implemented = GetGen<'interfaceNames'> | NexusInterfaceTypeDef<any>;

extensions?: GraphQLInterfaceTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -46,0 +54,0 @@ asNexusMethod?: string;

import { GraphQLObjectType } from 'graphql';
import type { InterfaceFieldsFor } from '../typegenTypeHelpers';
import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks';
import type { Directives } from './directive';
import type { FieldModification, FieldModificationDef, Implemented } from './interfaceType';

@@ -181,2 +182,9 @@ import { AbstractTypes, Maybe, NonNullConfig, SourceTypingDef } from './_types';

definition(t: ObjectDefinitionBlock<TypeName>): void;
/**
* A list of directives / directive uses (with args) for the object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -183,0 +191,0 @@ asNexusMethod?: string;

import { GraphQLNamedType, GraphQLScalarTypeConfig } from 'graphql';
import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs } from '../core';
import type { Directives } from './directive';
import { GraphQLNamedOutputType, Maybe, SourceTypingDef } from './_types';

@@ -19,2 +20,9 @@ export interface ScalarBase extends Pick<GraphQLScalarTypeConfig<any, any>, 'description' | 'serialize' | 'parseValue' | 'parseLiteral'> {

extensions?: GraphQLScalarTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the scalar type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
}

@@ -21,0 +29,0 @@ export interface NexusScalarTypeConfig<T extends string> extends ScalarBase, ScalarConfig {

import { GraphQLUnionTypeConfig } from 'graphql';
import type { Directives } from '../core';
import type { GetGen } from '../typegenTypeHelpers';

@@ -39,2 +40,9 @@ import type { NexusObjectTypeDef } from './objectType';

extensions?: GraphQLUnionTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the union type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -41,0 +49,0 @@ asNexusMethod?: string;

@@ -21,2 +21,4 @@ import { GraphQLInputType, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLType } from 'graphql';

import { NexusTypes, NexusWrappedSymbol } from './_types';
import type { NexusDirectiveDef } from './directive';
import type { NexusDirectiveUse } from '../core';
/** Input(named): Nexus only */

@@ -74,2 +76,4 @@ export declare type AllNexusNamedInputTypeDefs<T extends string = any> = NexusInputObjectTypeDef<T> | NexusEnumTypeDef<T> | NexusScalarTypeDef<T>;

export declare function isNexusPlugin(obj: any): obj is NexusPlugin;
export declare function isNexusDirective(obj: any): obj is NexusDirectiveDef;
export declare function isNexusDirectiveUse(obj: any): obj is NexusDirectiveUse;
export declare type NexusWrapKind = 'NonNull' | 'Null' | 'List';

@@ -76,0 +80,0 @@ export declare type NexusFinalWrapKind = 'NonNull' | 'List';

@@ -90,2 +90,8 @@ import { GraphQLList, GraphQLNonNull, isWrappingType, isListType, isNonNullType, } from 'graphql';

}
export function isNexusDirective(obj) {
return isNexusStruct(obj) && obj[NexusWrappedSymbol] === NexusTypes.Directive;
}
export function isNexusDirectiveUse(obj) {
return isNexusStruct(obj) && obj[NexusWrappedSymbol] === NexusTypes.DirectiveUse;
}
export function unwrapGraphQLDef(typeDef) {

@@ -92,0 +98,0 @@ const wrapping = [];

@@ -8,2 +8,3 @@ import { GraphQLNamedType } from 'graphql';

import type { NexusObjectTypeConfig } from './definitions/objectType';
import type { Directives } from './core';
export declare type NexusGraphQLNamedType = GraphQLNamedType & {

@@ -44,2 +45,3 @@ extensions?: {

sourceTypings: SourceTypings;
schemaDirectives?: Directives;
}

@@ -46,0 +48,0 @@ /**

@@ -5,2 +5,3 @@ import * as blocks from './blocks';

export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';
export { directive, addDirective } from './definitions/directive';
export { decorateType } from './definitions/decorateType';

@@ -7,0 +8,0 @@ export { enumType } from './definitions/enumType';

@@ -6,2 +6,3 @@ import * as blocks from './blocks';

export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';
export { directive, addDirective } from './definitions/directive';
export { decorateType } from './definitions/decorateType';

@@ -8,0 +9,0 @@ export { enumType } from './definitions/enumType';

@@ -20,1 +20,8 @@ import { ConfiguredTypegen, SchemaConfig } from './builder';

}
/** Builds the schema, we may return more than just the schema from this one day. */
export declare function makeSchemaInternal(config: SchemaConfig): {
schema: NexusGraphQLSchema;
missingTypes: Record<string, import("./definitions/_types").MissingType>;
finalConfig: import("./builder").BuilderConfig;
hasSDLDirectives: boolean;
};

@@ -1,6 +0,8 @@

import { __awaiter } from "tslib";
import { makeSchemaInternal } from './builder';
import { __awaiter, __rest } from "tslib";
import { GraphQLSchema, isObjectType, specifiedDirectives } from 'graphql';
import { isNexusObjectTypeDef } from './definitions/wrapping';
import { SchemaBuilder, } from './builder';
import { TypegenMetadata } from './typegenMetadata';
import { resolveTypegenConfig } from './typegenUtils';
import { assertNoMissingTypes, runAbstractTypeRuntimeChecks } from './utils';
import { assertNoMissingTypes, objValues, runAbstractTypeRuntimeChecks } from './utils';
/**

@@ -13,3 +15,3 @@ * Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any

export function makeSchema(config) {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);

@@ -21,3 +23,3 @@ const sdl = typegenConfig.outputs.schema;

// in the optional thunk for the typegen config
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema);
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives);
if (config.shouldExitAfterGenerateArtifacts) {

@@ -56,5 +58,5 @@ let typegenPath = '(not enabled)';

return __awaiter(this, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);
yield new TypegenMetadata(typegenConfig).generateArtifacts(schema);
yield new TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives);
assertNoMissingTypes(schema, missingTypes);

@@ -70,5 +72,5 @@ runAbstractTypeRuntimeChecks(schema, finalConfig.features);

generateSchema.withArtifacts = (config, typegen = null) => __awaiter(void 0, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);
const { schemaTypes, tsTypes, globalTypes } = yield new TypegenMetadata(typegenConfig).generateArtifactContents(schema, typegen);
const { schemaTypes, tsTypes, globalTypes } = yield new TypegenMetadata(typegenConfig).generateArtifactContents(schema, typegen, hasSDLDirectives);
assertNoMissingTypes(schema, missingTypes);

@@ -78,2 +80,39 @@ runAbstractTypeRuntimeChecks(schema, finalConfig.features);

});
/** Builds the schema, we may return more than just the schema from this one day. */
export function makeSchemaInternal(config) {
const builder = new SchemaBuilder(config);
builder.addTypes(config.types);
builder.addTypes(config.directives);
if (config.schemaRoots) {
builder.addTypes(config.schemaRoots);
}
function getRootType(rootType, defaultType) {
var _a, _b;
const rootTypeVal = (_b = (_a = config.schemaRoots) === null || _a === void 0 ? void 0 : _a[rootType]) !== null && _b !== void 0 ? _b : defaultType;
let returnVal = null;
if (typeof rootTypeVal === 'string') {
returnVal = typeMap[rootTypeVal];
}
else if (rootTypeVal) {
if (isNexusObjectTypeDef(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
else if (isObjectType(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
}
if (returnVal && !isObjectType(returnVal)) {
throw new Error(`Expected ${rootType} to be a objectType, saw ${returnVal.constructor.name}`);
}
return returnVal;
}
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns, customDirectives, schemaDirectives, hasSDLDirectives, } = builder.getFinalTypeMap();
const schema = new GraphQLSchema(Object.assign(Object.assign(Object.assign({}, extractGraphQLSchemaOptions(config)), { query: getRootType('query', 'Query'), mutation: getRootType('mutation', 'Mutation'), subscription: getRootType('subscription', 'Subscription'), types: objValues(typeMap), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: schemaExtension }), directives: [...specifiedDirectives, ...Object.values(customDirectives)] }), schemaDirectives));
onAfterBuildFns.forEach((fn) => fn(schema));
return { schema, missingTypes, finalConfig, hasSDLDirectives };
}
function extractGraphQLSchemaOptions(config) {
const { formatTypegen, nonNullDefaults, mergeSchema, outputs, shouldExitAfterGenerateArtifacts, shouldGenerateArtifacts, schemaRoots, sourceTypes, prettierConfig, plugins, customPrintSchemaFn, features, contextType } = config, graphqlConfigOpts = __rest(config, ["formatTypegen", "nonNullDefaults", "mergeSchema", "outputs", "shouldExitAfterGenerateArtifacts", "shouldGenerateArtifacts", "schemaRoots", "sourceTypes", "prettierConfig", "plugins", "customPrintSchemaFn", "features", "contextType"]);
return graphqlConfigOpts;
}
//# sourceMappingURL=makeSchema.js.map

@@ -20,4 +20,4 @@ import { GraphQLSchema } from 'graphql';

/** Generates the artifacts of the build based on what we know about the schema and how it was defined. */
generateArtifacts(schema: NexusGraphQLSchema): Promise<void>;
generateArtifactContents(schema: NexusGraphQLSchema, typegen: string | null | ConfiguredTypegen): Promise<{
generateArtifacts(schema: NexusGraphQLSchema, hasSDLDirectives: boolean): Promise<void>;
generateArtifactContents(schema: NexusGraphQLSchema, typegen: string | null | ConfiguredTypegen, hasSDLDirectives: boolean): Promise<{
schemaTypes: string;

@@ -30,3 +30,3 @@ tsTypes: string;

/** Generates the schema, adding any directives as necessary */
generateSchemaFile(schema: GraphQLSchema): string;
generateSchemaFile(schema: GraphQLSchema, hasSDLDirectives: boolean): string;
/** Generates the type definitions */

@@ -33,0 +33,0 @@ generateTypesFile(schema: NexusGraphQLSchema, typegenPath: string): Promise<string>;

@@ -5,2 +5,3 @@ import { __awaiter } from "tslib";

import { SDL_HEADER, TYPEGEN_HEADER } from './lang';
import { printSchemaWithDirectives } from './printSchemaWithDirectives';
import { typegenAutoConfig } from './typegenAutoConfig';

@@ -18,3 +19,3 @@ import { typegenFormatPrettier } from './typegenFormatPrettier';

/** Generates the artifacts of the build based on what we know about the schema and how it was defined. */
generateArtifacts(schema) {
generateArtifacts(schema, hasSDLDirectives) {
return __awaiter(this, void 0, void 0, function* () {

@@ -24,3 +25,3 @@ const sortedSchema = this.sortSchema(schema);

if (this.config.outputs.schema || typegen) {
const { schemaTypes, tsTypes, globalTypes } = yield this.generateArtifactContents(sortedSchema, typegen);
const { schemaTypes, tsTypes, globalTypes } = yield this.generateArtifactContents(sortedSchema, typegen, hasSDLDirectives);
if (this.config.outputs.schema) {

@@ -43,6 +44,6 @@ yield this.writeFile('schema', schemaTypes, this.config.outputs.schema);

}
generateArtifactContents(schema, typegen) {
generateArtifactContents(schema, typegen, hasSDLDirectives) {
return __awaiter(this, void 0, void 0, function* () {
const result = {
schemaTypes: this.generateSchemaFile(schema),
schemaTypes: this.generateSchemaFile(schema, hasSDLDirectives),
tsTypes: '',

@@ -117,6 +118,7 @@ globalTypes: null,

/** Generates the schema, adding any directives as necessary */
generateSchemaFile(schema) {
generateSchemaFile(schema, hasSDLDirectives) {
const printer = hasSDLDirectives ? printSchemaWithDirectives : printSchema;
let printedSchema = this.config.customPrintSchemaFn
? this.config.customPrintSchemaFn(schema)
: printSchema(schema);
: printer(schema);
return [SDL_HEADER, printedSchema].join('\n\n');

@@ -123,0 +125,0 @@ }

@@ -38,2 +38,3 @@ import type { TypegenInfo } from './builder';

private printHeadersCommon;
private printDirectives;
private printHeadersGlobal;

@@ -40,0 +41,0 @@ private printGenTypeMap;

import { __rest } from "tslib";
import { getNamedType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isSpecifiedScalarType, isUnionType, } from 'graphql';
import { getNamedType, isEnumType, isInputObjectType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isSpecifiedDirective, isSpecifiedScalarType, isUnionType, } from 'graphql';
import { SchemaDirectiveLocation } from './definitions/directive';
import { isNexusPrintedGenTyping, isNexusPrintedGenTypingImport } from './definitions/wrapping';

@@ -83,2 +84,3 @@ import { TYPEGEN_HEADER } from './lang';

this.printTypeNames('union', 'NexusGenUnionNames', 'NexusGenUnions'),
this.printDirectives(),
this.printIsTypeOfObjectTypeNames('NexusGenObjectsUsingAbstractStrategyIsTypeOf'),

@@ -100,2 +102,38 @@ this.printResolveTypeAbstractTypes('NexusGenAbstractsUsingStrategyResolveType'),

}
printDirectives() {
const customDirectives = this.schema.getDirectives().filter((d) => !isSpecifiedDirective(d));
const schemaDirectiveArgs = {};
// Gather the mappings between directives, locations, etc.
customDirectives.forEach((d) => {
d.locations.forEach((l) => {
var _a;
if (SchemaDirectiveLocation.includes(l)) {
schemaDirectiveArgs[d.name] = (_a = d.args) !== null && _a !== void 0 ? _a : undefined;
}
});
});
const directiveNames = Object.keys(schemaDirectiveArgs)
.map((i) => JSON.stringify(i))
.join(' | ');
const toPrint = [`export type NexusGenDirectives = ${directiveNames || 'never'}`];
// Print the mappings of the directive names -> args
// NexusGenDirectiveArgs
let directiveArgs = [`export interface NexusGenDirectiveArgs {`];
eachObj(schemaDirectiveArgs, (val, key) => {
if (val) {
directiveArgs.push(` ${key}: {`);
val.forEach((arg) => {
const [sep, rep] = this.normalizeArg(arg);
directiveArgs.push(` ${arg.name}${sep}${rep}`);
});
directiveArgs.push(` }`);
}
else {
directiveArgs.push(` ${key}: never`);
}
});
directiveArgs.push('}');
toPrint.push(directiveArgs.join('\n'));
return toPrint.join('\n\n');
}
printHeadersGlobal() {

@@ -121,2 +159,4 @@ var _a, _b;

` inputTypes: NexusGenInputs;`,
` directives: NexusGenDirectives;`,
` directiveArgs: NexusGenDirectiveArgs;`,
` rootTypes: NexusGenRootTypes;`,

@@ -123,0 +163,0 @@ ` inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars;`,

@@ -106,11 +106,11 @@ import type { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql';

/** Generated type helpers: */
export declare type GenTypesShapeKeys = 'context' | 'inputTypes' | 'rootTypes' | 'inputTypeShapes' | 'argTypes' | 'fieldTypes' | 'fieldTypeNames' | 'allTypes' | 'typeInterfaces' | 'objectNames' | 'inputNames' | 'enumNames' | 'interfaceNames' | 'scalarNames' | 'unionNames' | 'allInputTypes' | 'allOutputTypes' | 'allNamedTypes' | 'abstractTypes' | 'abstractTypeMembers' | 'objectsUsingAbstractStrategyIsTypeOf' | 'abstractsUsingStrategyResolveType' | 'features';
export declare type GenTypesShapeKeys = 'context' | 'inputTypes' | 'rootTypes' | 'inputTypeShapes' | 'directives' | 'directiveArgs' | 'argTypes' | 'fieldTypes' | 'fieldTypeNames' | 'allTypes' | 'typeInterfaces' | 'objectNames' | 'inputNames' | 'enumNames' | 'interfaceNames' | 'scalarNames' | 'unionNames' | 'allInputTypes' | 'allOutputTypes' | 'allNamedTypes' | 'abstractTypes' | 'abstractTypeMembers' | 'objectsUsingAbstractStrategyIsTypeOf' | 'abstractsUsingStrategyResolveType' | 'features';
/** Helpers for handling the generated schema */
export declare type GenTypesShape = Record<GenTypesShapeKeys, any>;
export declare type GetGen<K extends GenTypesShapeKeys, Fallback = any> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? GenTypes[K] : Fallback : Fallback;
export declare type GetGen<K extends GenTypesShapeKeys, Fallback = any> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? GenTypes[K] : Fallback : Fallback;
export declare type GetGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, Fallback = any> = K2 extends keyof GetGen<K, never> ? GetGen<K>[K2] : Fallback;
export declare type GetGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>, Fallback = any> = K2 extends keyof GetGen<K, never> ? K3 extends keyof GetGen<K>[K2] ? GetGen<K>[K2][K3] : Fallback : Fallback;
export declare type HasGen<K extends GenTypesShapeKeys> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? true : false : false : false;
export declare type HasGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? true : false : false : false : false;
export declare type HasGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? K3 extends keyof GenTypes[K][K2] ? true : false : false : false : false : false;
export declare type HasGen<K extends GenTypesShapeKeys> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? true : false : false;
export declare type HasGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? true : false : false : false;
export declare type HasGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? K3 extends keyof GenTypes[K][K2] ? true : false : false : false : false;
export declare type SourceValue<TypeName extends string> = GetGen2<'rootTypes', TypeName>;

@@ -117,0 +117,0 @@ export declare type RootValueField<TypeName extends string, FieldName extends string> = GetGen3<'rootTypes', TypeName, FieldName>;

@@ -40,2 +40,3 @@ /**

export declare type UnwrapPromise<R> = R extends PromiseLike<infer U> ? U : R;
export declare type MaybeReadonlyArray<T> = Array<T> | ReadonlyArray<T>;
export {};

@@ -1,2 +0,2 @@

import { GraphQLNamedType, GraphQLSchema, GraphQLSchemaConfig, printSchema } from 'graphql';
import { ASTKindToNode, GraphQLDirective, GraphQLNamedType, GraphQLSchema, GraphQLSchemaConfig, printSchema } from 'graphql';
import { InputDefinitionBlock } from './definitions/definitionBlocks';

@@ -8,3 +8,3 @@ import type { NexusExtendInputTypeDef } from './definitions/extendInputType';

import { AllNexusNamedTypeDefs, AllNexusOutputTypeDefs } from './definitions/wrapping';
import type { MissingType, NexusFeaturesInput, NexusGraphQLSchema, NonNullConfig, TypingImport } from './definitions/_types';
import type { MissingType, NexusFeaturesInput, NonNullConfig, TypingImport } from './definitions/_types';
import type { DynamicInputMethodDef, DynamicOutputMethodDef } from './dynamicMethod';

@@ -19,2 +19,3 @@ import type { DynamicOutputPropertyDef } from './dynamicProperty';

import { NexusMeta } from './definitions/nexusMeta';
import { Directives, NexusDirectiveConfig, NexusDirectiveDef } from './definitions/directive';
declare type NexusShapedOutput = {

@@ -185,2 +186,9 @@ name: string;

plugins: RequiredDeeply<BuilderConfigInput['plugins']>;
/**
* A list of directives / directive uses (with args) for the schema definition
*
* @example
* schemaDirectives: [addDirective('ExampleDirective', { arg: true })]
*/
schemaDirectives?: Directives;
}

@@ -245,2 +253,5 @@ /**

value: NexusInterfaceTypeConfig<any>;
} | {
type: 'directive';
value: NexusDirectiveConfig;
};

@@ -252,3 +263,3 @@ export declare type DynamicInputFields = Record<string, DynamicInputMethodDef<string> | string>;

export declare type DynamicBlockDef = DynamicInputMethodDef<string> | DynamicOutputMethodDef<string> | DynamicOutputPropertyDef<string>;
export declare type NexusAcceptedTypeDef = TypeDef | DynamicBlockDef | NexusMeta;
export declare type NexusAcceptedTypeDef = TypeDef | DynamicBlockDef | NexusMeta | NexusDirectiveDef | GraphQLDirective;
export declare type PluginBuilderLens = {

@@ -302,2 +313,9 @@ hasType: SchemaBuilder['hasType'];

private plugins;
/** All GraphQL Directives */
private directivesMap;
/** All Directives that are defined */
private pendingDirectives;
/** All Schema Directives */
/** Whether we have used any custom directives within the schema construction */
private hasSDLDirectives;
/** All types that need to be traversed for children types */

@@ -361,2 +379,5 @@ private typesToWalk;

private addInputField;
private addDirective;
private buildDirective;
private maybeAddDirectiveUses;
private buildEnumType;

@@ -382,2 +403,3 @@ private buildUnionType;

private getOrBuildType;
private walkDirectiveDef;
private walkInputType;

@@ -413,10 +435,9 @@ private addDynamicInputFields;

onAfterBuildFns: SchemaBuilder['onAfterBuildFns'];
customDirectives: Record<string, GraphQLDirective>;
hasSDLDirectives: boolean;
schemaDirectives?: Partial<{
astNode: ASTKindToNode['SchemaDefinition'];
}>;
}
/** Builds the schema, we may return more than just the schema from this one day. */
export declare function makeSchemaInternal(config: SchemaConfig): {
schema: NexusGraphQLSchema;
missingTypes: Record<string, MissingType>;
finalConfig: BuilderConfig;
};
export declare function setConfigDefaults(config: BuilderConfigInput): BuilderConfig;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setConfigDefaults = exports.makeSchemaInternal = exports.SchemaBuilder = void 0;
exports.setConfigDefaults = exports.SchemaBuilder = void 0;
const tslib_1 = require("tslib");

@@ -18,2 +18,3 @@ const graphql_1 = require("graphql");

const nexusMeta_1 = require("./definitions/nexusMeta");
const directive_1 = require("./definitions/directive");
const rebuildType_1 = require("./rebuildType");

@@ -69,2 +70,10 @@ const SCALARS = {

this.plugins = [];
/** All GraphQL Directives */
this.directivesMap = {};
/** All Directives that are defined */
this.pendingDirectives = {};
/** All Schema Directives */
// private schemaDirectives: GraphQLDirective[] = []
/** Whether we have used any custom directives within the schema construction */
this.hasSDLDirectives = false;
/** All types that need to be traversed for children types */

@@ -130,2 +139,11 @@ this.typesToWalk = [];

}
if ((0, wrapping_1.isNexusDirective)(typeDef)) {
this.typesToWalk.push({ type: 'directive', value: typeDef.value });
const existingDirective = this.pendingDirectives[typeDef.value.name];
if (existingDirective && existingDirective !== typeDef.value) {
console.error(new Error(`Already have a directive named ${typeDef.value.name}`));
}
this.pendingDirectives[typeDef.value.name] = typeDef.value;
return;
}
if ((0, nexusMeta_1.isNexusMeta)(typeDef)) {

@@ -174,2 +192,6 @@ this.addToNexusMeta(typeDef);

}
if ((0, graphql_1.isDirective)(typeDef)) {
this.addDirective(typeDef);
return;
}
// If it's a concrete GraphQL type, we handle it directly by convering the

@@ -262,2 +284,3 @@ // type to a Nexus structure, and capturing all of the referenced types

this.addTypes(types.getTypeMap());
this.addTypes(types.getDirectives());
}

@@ -276,2 +299,4 @@ return;

(0, graphql_1.isNamedType)(types) ||
(0, graphql_1.isDirective)(types) ||
(0, wrapping_1.isNexusDirective)(types) ||
(0, wrapping_1.isNexusDynamicInputMethod)(types) ||

@@ -316,2 +341,5 @@ (0, wrapping_1.isNexusDynamicOutputMethod)(types) ||

break;
case 'directive':
this.walkDirectiveDef(obj.value);
break;
default:

@@ -423,2 +451,6 @@ (0, utils_1.casesHandled)(obj);

}
Object.keys(this.pendingDirectives).forEach((key) => {
const directiveDef = this.pendingDirectives[key];
this.directivesMap[directiveDef.name] = this.buildDirective(directiveDef);
});
Object.keys(this.pendingTypeMap).forEach((key) => {

@@ -478,2 +510,5 @@ if (this.typesToWalk.length > 0) {

onAfterBuildFns: this.onAfterBuildFns,
customDirectives: this.directivesMap,
hasSDLDirectives: this.hasSDLDirectives,
schemaDirectives: this.maybeAddDirectiveUses('SCHEMA', this.config.schemaDirectives),
};

@@ -511,8 +546,3 @@ }

this.inputTypeExtendMap[config.name] = null;
const inputObjectTypeConfig = {
name: config.name,
fields: () => this.buildInputObjectFields(fields, inputObjectTypeConfig),
description: config.description,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusInputObjectTypeExtension(config) }),
};
const inputObjectTypeConfig = Object.assign({ name: config.name, fields: () => this.buildInputObjectFields(fields, inputObjectTypeConfig), description: config.description, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusInputObjectTypeExtension(config) }) }, this.maybeAddDirectiveUses('INPUT_OBJECT', config.directives));
return this.finalize(new graphql_1.GraphQLInputObjectType(inputObjectTypeConfig));

@@ -550,10 +580,3 @@ }

}
const objectTypeConfig = {
name: config.name,
interfaces: () => this.buildInterfaceList(interfaces),
description: config.description,
fields: () => this.buildOutputFields(fields, objectTypeConfig, this.buildInterfaceFields(objectTypeConfig, interfaces, modifications)),
isTypeOf: config.isTypeOf,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusObjectTypeExtension(config) }),
};
const objectTypeConfig = Object.assign({ name: config.name, interfaces: () => this.buildInterfaceList(interfaces), description: config.description, fields: () => this.buildOutputFields(fields, objectTypeConfig, this.buildInterfaceFields(objectTypeConfig, interfaces, modifications)), isTypeOf: config.isTypeOf, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusObjectTypeExtension(config) }) }, this.maybeAddDirectiveUses('OBJECT', config.directives));
return this.finalize(new graphql_1.GraphQLObjectType(objectTypeConfig));

@@ -583,10 +606,4 @@ }

}
const interfaceTypeConfig = {
name,
interfaces: () => this.buildInterfaceList(interfaces),
resolveType,
description,
fields: () => this.buildOutputFields(fields, interfaceTypeConfig, this.buildInterfaceFields(interfaceTypeConfig, interfaces, modifications)),
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusInterfaceTypeExtension(config) }),
};
const interfaceTypeConfig = Object.assign({ name, interfaces: () => this.buildInterfaceList(interfaces), resolveType,
description, fields: () => this.buildOutputFields(fields, interfaceTypeConfig, this.buildInterfaceFields(interfaceTypeConfig, interfaces, modifications)), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: new extensions_1.NexusInterfaceTypeExtension(config) }) }, this.maybeAddDirectiveUses('INTERFACE', config.directives));
return this.finalize(new graphql_1.GraphQLInterfaceType(interfaceTypeConfig));

@@ -612,2 +629,38 @@ }

}
addDirective(kind) {
if ((0, wrapping_1.isNexusDirectiveUse)(kind)) {
if (kind.config && !this.pendingDirectives[kind.name]) {
this.directivesMap[kind.name] = this.buildDirective(kind.config);
}
}
else if ((0, graphql_1.isDirective)(kind)) {
this.directivesMap[kind.name] = kind;
}
else if ((0, wrapping_1.isNexusDirective)(kind)) {
this.directivesMap[kind.value.name] = this.buildDirective(kind.value);
}
}
buildDirective(config) {
return new graphql_1.GraphQLDirective({
name: config.name,
args: config.args ? this.buildArgs(config.args, config, 'directive') : undefined,
locations: config.locations,
isRepeatable: config.isRepeatable,
extensions: config.extensions,
description: config.description,
});
}
maybeAddDirectiveUses(kind, directives) {
if (!directives) {
return;
}
for (const directive of directives) {
this.addDirective(directive);
}
const result = (0, directive_1.maybeAddDirectiveUses)(kind, directives, this.directivesMap);
if (result) {
this.hasSDLDirectives = true;
}
return result;
}
buildEnumType(config) {

@@ -654,8 +707,3 @@ var _a, _b;

}
return this.finalize(new graphql_1.GraphQLEnumType({
name: config.name,
values: values,
description: config.description,
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }),
}));
return this.finalize(new graphql_1.GraphQLEnumType(Object.assign({ name: config.name, values: values, description: config.description, extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }, this.maybeAddDirectiveUses('ENUM', config.directives))));
}

@@ -673,9 +721,3 @@ buildUnionType(config) {

}
return this.finalize(new graphql_1.GraphQLUnionType({
name: config.name,
resolveType,
description: config.description,
types: () => this.buildUnionMembers(config.name, members),
extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }),
}));
return this.finalize(new graphql_1.GraphQLUnionType(Object.assign({ name: config.name, resolveType, description: config.description, types: () => this.buildUnionMembers(config.name, members), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }, this.maybeAddDirectiveUses('UNION', config.directives))));
}

@@ -687,3 +729,3 @@ buildScalarType(config) {

}
return this.finalize(new graphql_1.GraphQLScalarType(Object.assign(Object.assign({}, config), { extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) })));
return this.finalize(new graphql_1.GraphQLScalarType(Object.assign(Object.assign(Object.assign({}, config), { extensions: Object.assign(Object.assign({}, config.extensions), { nexus: (_b = (_a = config.extensions) === null || _a === void 0 ? void 0 : _a.nexus) !== null && _b !== void 0 ? _b : {} }) }), this.maybeAddDirectiveUses('SCALAR', config.directives))));
}

@@ -812,10 +854,3 @@ finalize(type) {

const finalWrap = (0, wrapping_1.finalizeWrapping)(nonNullDefault, wrapping, fieldConfig.wrapping);
const builderFieldConfig = {
name: fieldConfig.name,
type: (0, wrapping_1.rewrapAsGraphQLType)(this.getOutputType(namedType), finalWrap),
args: this.buildArgs(fieldConfig.args || {}, typeConfig, fieldConfig.name),
description: fieldConfig.description,
deprecationReason: fieldConfig.deprecation,
extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: fieldExtension }),
};
const builderFieldConfig = Object.assign({ name: fieldConfig.name, type: (0, wrapping_1.rewrapAsGraphQLType)(this.getOutputType(namedType), finalWrap), args: this.buildArgs(fieldConfig.args || {}, typeConfig, fieldConfig.name), description: fieldConfig.description, deprecationReason: fieldConfig.deprecation, extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: fieldExtension }) }, this.maybeAddDirectiveUses('FIELD_DEFINITION', fieldConfig.directives));
return Object.assign({ resolve: this.makeFinalResolver({

@@ -844,8 +879,3 @@ builder: this.builderLens,

const finalWrap = (0, wrapping_1.finalizeWrapping)(nonNullDefault, wrapping, fieldConfig.wrapping);
return {
type: (0, wrapping_1.rewrapAsGraphQLType)(this.getInputType(namedType), finalWrap),
defaultValue: fieldConfig.default,
description: fieldConfig.description,
extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: (_d = (_c = fieldConfig.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }),
};
return Object.assign({ type: (0, wrapping_1.rewrapAsGraphQLType)(this.getInputType(namedType), finalWrap), defaultValue: fieldConfig.default, description: fieldConfig.description, extensions: Object.assign(Object.assign({}, fieldConfig.extensions), { nexus: (_d = (_c = fieldConfig.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }) }, this.maybeAddDirectiveUses('INPUT_FIELD_DEFINITION', fieldConfig.directives));
}

@@ -867,8 +897,3 @@ buildArgs(args, typeConfig, fieldName) {

const finalWrap = (0, wrapping_1.finalizeWrapping)(nonNullDefault, wrapping);
allArgs[argName] = {
type: (0, wrapping_1.rewrapAsGraphQLType)(this.getInputType(namedType), finalWrap),
description: finalArgDef.description,
defaultValue: finalArgDef.default,
extensions: Object.assign(Object.assign({}, finalArgDef.extensions), { nexus: (_d = (_c = finalArgDef.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }),
};
allArgs[argName] = Object.assign({ type: (0, wrapping_1.rewrapAsGraphQLType)(this.getInputType(namedType), finalWrap), description: finalArgDef.description, defaultValue: finalArgDef.default, extensions: Object.assign(Object.assign({}, finalArgDef.extensions), { nexus: (_d = (_c = finalArgDef.extensions) === null || _c === void 0 ? void 0 : _c.nexus) !== null && _d !== void 0 ? _d : {} }) }, this.maybeAddDirectiveUses('ARGUMENT_DEFINITION', finalArgDef.directives));
}

@@ -959,2 +984,7 @@ return allArgs;

}
walkDirectiveDef(def) {
if (def.args) {
this.traverseArgs(def.args);
}
}
walkInputType(obj) {

@@ -1116,4 +1146,7 @@ const definitionBlock = new definitionBlocks_1.InputDefinitionBlock({

var _a;
const { types } = config.schema.toConfig();
const { types, directives } = config.schema.toConfig();
const mergedTypes = {};
for (const directive of directives) {
this.addDirective(directive);
}
// We don't need to worry about capturing any types while walking,

@@ -1146,39 +1179,2 @@ // because we have the entire schema

}
/** Builds the schema, we may return more than just the schema from this one day. */
function makeSchemaInternal(config) {
const builder = new SchemaBuilder(config);
builder.addTypes(config.types);
if (config.schemaRoots) {
builder.addTypes(config.schemaRoots);
}
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns } = builder.getFinalTypeMap();
function getRootType(rootType, defaultType) {
var _a, _b;
const rootTypeVal = (_b = (_a = config.schemaRoots) === null || _a === void 0 ? void 0 : _a[rootType]) !== null && _b !== void 0 ? _b : defaultType;
let returnVal = null;
if (typeof rootTypeVal === 'string') {
returnVal = typeMap[rootTypeVal];
}
else if (rootTypeVal) {
if ((0, wrapping_1.isNexusObjectTypeDef)(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
else if ((0, graphql_1.isObjectType)(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
}
if (returnVal && !(0, graphql_1.isObjectType)(returnVal)) {
throw new Error(`Expected ${rootType} to be a objectType, saw ${returnVal.constructor.name}`);
}
return returnVal;
}
const schema = new graphql_1.GraphQLSchema(Object.assign(Object.assign({}, extractGraphQLSchemaOptions(config)), { query: getRootType('query', 'Query'), mutation: getRootType('mutation', 'Mutation'), subscription: getRootType('subscription', 'Subscription'), types: (0, utils_1.objValues)(typeMap), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: schemaExtension }) }));
onAfterBuildFns.forEach((fn) => fn(schema));
return { schema, missingTypes, finalConfig };
}
exports.makeSchemaInternal = makeSchemaInternal;
function extractGraphQLSchemaOptions(config) {
const { formatTypegen, nonNullDefaults, mergeSchema, outputs, shouldExitAfterGenerateArtifacts, shouldGenerateArtifacts, schemaRoots, sourceTypes, prettierConfig, plugins, customPrintSchemaFn, features, contextType } = config, graphqlConfigOpts = (0, tslib_1.__rest)(config, ["formatTypegen", "nonNullDefaults", "mergeSchema", "outputs", "shouldExitAfterGenerateArtifacts", "shouldGenerateArtifacts", "schemaRoots", "sourceTypes", "prettierConfig", "plugins", "customPrintSchemaFn", "features", "contextType"]);
return graphqlConfigOpts;
}
function setConfigDefaults(config) {

@@ -1185,0 +1181,0 @@ var _a, _b, _c, _d, _e;

export * from './builder';
export * from './makeSchema';
export * from './definitions/args';
export * from './definitions/directive';
export * from './definitions/decorateType';

@@ -5,0 +6,0 @@ export * from './definitions/definitionBlocks';

@@ -9,2 +9,3 @@ "use strict";

(0, tslib_1.__exportStar)(require("./definitions/args"), exports);
(0, tslib_1.__exportStar)(require("./definitions/directive"), exports);
(0, tslib_1.__exportStar)(require("./definitions/decorateType"), exports);

@@ -11,0 +12,0 @@ (0, tslib_1.__exportStar)(require("./definitions/definitionBlocks"), exports);

import type { GraphQLCompositeType, GraphQLEnumType, GraphQLFieldConfig, GraphQLInputObjectType, GraphQLInputObjectTypeConfig, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLLeafType, GraphQLObjectType, GraphQLObjectTypeConfig, GraphQLScalarType, GraphQLSchema, GraphQLUnionType } from 'graphql';
import type { NexusDirectiveConfig } from '../core';
import type { NexusFieldExtension, NexusInputObjectTypeExtension, NexusInterfaceTypeExtension, NexusObjectTypeExtension, NexusSchemaExtension } from '../extensions';

@@ -30,3 +31,5 @@ import type * as AbstractTypes from '../typegenAbstractTypes';

Scalar = "Scalar",
Union = "Union"
Union = "Union",
Directive = "Directive",
DirectiveUse = "DirectiveUse"
}

@@ -105,2 +108,3 @@ export interface DeprecationInfo {

};
export declare type NexusGraphQLDirectiveConfig = WithExt<NexusDirectiveConfig, NexusInputObjectTypeExtension>;
export interface NexusGraphQLSchema extends GraphQLSchema {

@@ -107,0 +111,0 @@ extensions: {

@@ -26,2 +26,4 @@ "use strict";

NexusTypes["Union"] = "Union";
NexusTypes["Directive"] = "Directive";
NexusTypes["DirectiveUse"] = "DirectiveUse";
})(NexusTypes = exports.NexusTypes || (exports.NexusTypes = {}));

@@ -28,0 +30,0 @@ exports.NexusWrappedSymbol = Symbol.for('@nexus/wrapped');

import type { GraphQLScalarTypeConfig } from 'graphql';
import type { AllInputTypes, GetGen2 } from '../typegenTypeHelpers';
import type { Directives } from './directive';
import type { AllNexusArgsDefs, AllNexusInputTypeDefs } from './wrapping';

@@ -47,2 +48,9 @@ import { Maybe } from './_types';

extensions?: GraphQLScalarTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the arg definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginArgConfig;

@@ -49,0 +57,0 @@ export interface ScalarArgConfig<T> extends CommonArgConfig {

import type { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLInputFieldConfig } from 'graphql';
import type { AllInputTypes, FieldResolver, GetGen, GetGen3, HasGen3, NeedsResolver } from '../typegenTypeHelpers';
import type { ArgsRecord } from './args';
import type { Directives } from './directive';
import type { NexusMetaType } from './nexusMeta';

@@ -96,2 +97,9 @@ import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping';

extensions?: GraphQLFieldConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginFieldConfig<TypeName, FieldName>;

@@ -107,2 +115,9 @@ export declare type CommonInputFieldConfig<TypeName extends string, FieldName extends string> = CommonFieldConfig & {

extensions?: GraphQLInputFieldConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the input field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
} & NexusGenPluginFieldConfig<TypeName, FieldName> & NexusGenPluginInputFieldConfig<TypeName, FieldName>;

@@ -109,0 +124,0 @@ export interface OutputScalarConfig<TypeName extends string, FieldName extends string> extends CommonOutputFieldConfig<TypeName, FieldName> {

import { GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql';
import { NexusArgDef, NexusAsArgConfig } from './args';
import type { Directives } from './directive';
import { Maybe, SourceTypingDef } from './_types';

@@ -25,2 +26,9 @@ declare type TypeScriptEnumLike = {

extensions?: GraphQLEnumValueConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the enum member definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
}

@@ -41,2 +49,9 @@ export interface NexusEnumTypeConfig<TypeName extends string> {

extensions?: GraphQLEnumTypeConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the enum type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -43,0 +58,0 @@ asNexusMethod?: string;

import { GraphQLInputObjectTypeConfig } from 'graphql';
import { NexusArgDef, NexusAsArgConfig } from './args';
import type { InputDefinitionBlock } from './definitionBlocks';
import type { Directives } from './directive';
import { Maybe, NonNullConfig } from './_types';

@@ -23,2 +24,9 @@ export declare type NexusInputObjectTypeConfig<TypeName extends string> = {

extensions?: GraphQLInputObjectTypeConfig['extensions'];
/**
* A list of directives / directive uses (with args) for the input object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -25,0 +33,0 @@ asNexusMethod?: string;

@@ -5,2 +5,3 @@ import { GraphQLInterfaceTypeConfig } from 'graphql';

import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks';
import type { Directives } from './directive';
import { AbstractTypes, Maybe, NonNullConfig, SourceTypingDef } from './_types';

@@ -44,2 +45,9 @@ export declare type Implemented = GetGen<'interfaceNames'> | NexusInterfaceTypeDef<any>;

extensions?: GraphQLInterfaceTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -46,0 +54,0 @@ asNexusMethod?: string;

import { GraphQLObjectType } from 'graphql';
import type { InterfaceFieldsFor } from '../typegenTypeHelpers';
import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks';
import type { Directives } from './directive';
import type { FieldModification, FieldModificationDef, Implemented } from './interfaceType';

@@ -181,2 +182,9 @@ import { AbstractTypes, Maybe, NonNullConfig, SourceTypingDef } from './_types';

definition(t: ObjectDefinitionBlock<TypeName>): void;
/**
* A list of directives / directive uses (with args) for the object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -183,0 +191,0 @@ asNexusMethod?: string;

import { GraphQLNamedType, GraphQLScalarTypeConfig } from 'graphql';
import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs } from '../core';
import type { Directives } from './directive';
import { GraphQLNamedOutputType, Maybe, SourceTypingDef } from './_types';

@@ -19,2 +20,9 @@ export interface ScalarBase extends Pick<GraphQLScalarTypeConfig<any, any>, 'description' | 'serialize' | 'parseValue' | 'parseLiteral'> {

extensions?: GraphQLScalarTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the scalar type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
}

@@ -21,0 +29,0 @@ export interface NexusScalarTypeConfig<T extends string> extends ScalarBase, ScalarConfig {

import { GraphQLUnionTypeConfig } from 'graphql';
import type { Directives } from '../core';
import type { GetGen } from '../typegenTypeHelpers';

@@ -39,2 +40,9 @@ import type { NexusObjectTypeDef } from './objectType';

extensions?: GraphQLUnionTypeConfig<any, any>['extensions'];
/**
* A list of directives / directive uses (with args) for the union type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives;
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -41,0 +49,0 @@ asNexusMethod?: string;

@@ -21,2 +21,4 @@ import { GraphQLInputType, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLType } from 'graphql';

import { NexusTypes, NexusWrappedSymbol } from './_types';
import type { NexusDirectiveDef } from './directive';
import type { NexusDirectiveUse } from '../core';
/** Input(named): Nexus only */

@@ -74,2 +76,4 @@ export declare type AllNexusNamedInputTypeDefs<T extends string = any> = NexusInputObjectTypeDef<T> | NexusEnumTypeDef<T> | NexusScalarTypeDef<T>;

export declare function isNexusPlugin(obj: any): obj is NexusPlugin;
export declare function isNexusDirective(obj: any): obj is NexusDirectiveDef;
export declare function isNexusDirectiveUse(obj: any): obj is NexusDirectiveUse;
export declare type NexusWrapKind = 'NonNull' | 'Null' | 'List';

@@ -76,0 +80,0 @@ export declare type NexusFinalWrapKind = 'NonNull' | 'List';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.finalizeWrapping = exports.applyNexusWrapping = exports.normalizeArgWrapping = exports.rewrapAsGraphQLType = exports.unwrapNexusDef = exports.unwrapGraphQLDef = exports.isNexusPlugin = exports.isNexusPrintedGenTypingImport = exports.isNexusPrintedGenTyping = exports.isNexusDynamicInputMethod = exports.isNexusDynamicOutputMethod = exports.isNexusDynamicOutputProperty = exports.isNexusNamedInputTypeDef = exports.isNexusNamedOuputTypeDef = exports.isNexusArgDef = exports.isNexusInterfaceTypeDef = exports.isNexusUnionTypeDef = exports.isNexusScalarTypeDef = exports.isNexusObjectTypeDef = exports.isNexusInputObjectTypeDef = exports.isNexusEnumTypeDef = exports.isNexusExtendTypeDef = exports.isNexusExtendInputTypeDef = exports.isNexusWrappingType = exports.isNexusNullTypeDef = exports.isNexusNonNullTypeDef = exports.isNexusListTypeDef = exports.isNexusNamedTypeDef = exports.isNexusStruct = exports.isNexusTypeDef = void 0;
exports.finalizeWrapping = exports.applyNexusWrapping = exports.normalizeArgWrapping = exports.rewrapAsGraphQLType = exports.unwrapNexusDef = exports.unwrapGraphQLDef = exports.isNexusDirectiveUse = exports.isNexusDirective = exports.isNexusPlugin = exports.isNexusPrintedGenTypingImport = exports.isNexusPrintedGenTyping = exports.isNexusDynamicInputMethod = exports.isNexusDynamicOutputMethod = exports.isNexusDynamicOutputProperty = exports.isNexusNamedInputTypeDef = exports.isNexusNamedOuputTypeDef = exports.isNexusArgDef = exports.isNexusInterfaceTypeDef = exports.isNexusUnionTypeDef = exports.isNexusScalarTypeDef = exports.isNexusObjectTypeDef = exports.isNexusInputObjectTypeDef = exports.isNexusEnumTypeDef = exports.isNexusExtendTypeDef = exports.isNexusExtendInputTypeDef = exports.isNexusWrappingType = exports.isNexusNullTypeDef = exports.isNexusNonNullTypeDef = exports.isNexusListTypeDef = exports.isNexusNamedTypeDef = exports.isNexusStruct = exports.isNexusTypeDef = void 0;
const graphql_1 = require("graphql");

@@ -117,2 +117,10 @@ const utils_1 = require("../utils");

exports.isNexusPlugin = isNexusPlugin;
function isNexusDirective(obj) {
return isNexusStruct(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.Directive;
}
exports.isNexusDirective = isNexusDirective;
function isNexusDirectiveUse(obj) {
return isNexusStruct(obj) && obj[_types_1.NexusWrappedSymbol] === _types_1.NexusTypes.DirectiveUse;
}
exports.isNexusDirectiveUse = isNexusDirectiveUse;
function unwrapGraphQLDef(typeDef) {

@@ -119,0 +127,0 @@ const wrapping = [];

@@ -8,2 +8,3 @@ import { GraphQLNamedType } from 'graphql';

import type { NexusObjectTypeConfig } from './definitions/objectType';
import type { Directives } from './core';
export declare type NexusGraphQLNamedType = GraphQLNamedType & {

@@ -44,2 +45,3 @@ extensions?: {

sourceTypings: SourceTypings;
schemaDirectives?: Directives;
}

@@ -46,0 +48,0 @@ /**

@@ -5,2 +5,3 @@ import * as blocks from './blocks';

export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';
export { directive, addDirective } from './definitions/directive';
export { decorateType } from './definitions/decorateType';

@@ -7,0 +8,0 @@ export { enumType } from './definitions/enumType';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.core = exports.blocks = exports.groupTypes = exports.convertSDL = exports.plugin = exports.createPlugin = exports.dynamicOutputProperty = exports.dynamicOutputMethod = exports.dynamicInputMethod = exports.unionType = exports.subscriptionType = exports.subscriptionField = exports.scalarType = exports.asNexusMethod = exports.queryType = exports.queryField = exports.objectType = exports.nullable = exports.nonNull = exports.mutationType = exports.mutationField = exports.list = exports.interfaceType = exports.inputObjectType = exports.extendType = exports.extendInputType = exports.enumType = exports.decorateType = exports.stringArg = exports.intArg = exports.idArg = exports.floatArg = exports.booleanArg = exports.arg = exports.makeSchema = void 0;
exports.core = exports.blocks = exports.groupTypes = exports.convertSDL = exports.plugin = exports.createPlugin = exports.dynamicOutputProperty = exports.dynamicOutputMethod = exports.dynamicInputMethod = exports.unionType = exports.subscriptionType = exports.subscriptionField = exports.scalarType = exports.asNexusMethod = exports.queryType = exports.queryField = exports.objectType = exports.nullable = exports.nonNull = exports.mutationType = exports.mutationField = exports.list = exports.interfaceType = exports.inputObjectType = exports.extendType = exports.extendInputType = exports.enumType = exports.decorateType = exports.addDirective = exports.directive = exports.stringArg = exports.intArg = exports.idArg = exports.floatArg = exports.booleanArg = exports.arg = exports.makeSchema = void 0;
const tslib_1 = require("tslib");

@@ -19,2 +19,5 @@ const blocks = (0, tslib_1.__importStar)(require("./blocks"));

Object.defineProperty(exports, "stringArg", { enumerable: true, get: function () { return args_1.stringArg; } });
var directive_1 = require("./definitions/directive");
Object.defineProperty(exports, "directive", { enumerable: true, get: function () { return directive_1.directive; } });
Object.defineProperty(exports, "addDirective", { enumerable: true, get: function () { return directive_1.addDirective; } });
var decorateType_1 = require("./definitions/decorateType");

@@ -21,0 +24,0 @@ Object.defineProperty(exports, "decorateType", { enumerable: true, get: function () { return decorateType_1.decorateType; } });

@@ -20,1 +20,8 @@ import { ConfiguredTypegen, SchemaConfig } from './builder';

}
/** Builds the schema, we may return more than just the schema from this one day. */
export declare function makeSchemaInternal(config: SchemaConfig): {
schema: NexusGraphQLSchema;
missingTypes: Record<string, import("./definitions/_types").MissingType>;
finalConfig: import("./builder").BuilderConfig;
hasSDLDirectives: boolean;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSchema = exports.makeSchema = void 0;
exports.makeSchemaInternal = exports.generateSchema = exports.makeSchema = void 0;
const tslib_1 = require("tslib");
const graphql_1 = require("graphql");
const wrapping_1 = require("./definitions/wrapping");
const builder_1 = require("./builder");

@@ -16,3 +18,3 @@ const typegenMetadata_1 = require("./typegenMetadata");

function makeSchema(config) {
const { schema, missingTypes, finalConfig } = (0, builder_1.makeSchemaInternal)(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = (0, typegenUtils_1.resolveTypegenConfig)(finalConfig);

@@ -24,3 +26,3 @@ const sdl = typegenConfig.outputs.schema;

// in the optional thunk for the typegen config
const typegenPromise = new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema);
const typegenPromise = new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives);
if (config.shouldExitAfterGenerateArtifacts) {

@@ -60,5 +62,5 @@ let typegenPath = '(not enabled)';

return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = (0, builder_1.makeSchemaInternal)(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = (0, typegenUtils_1.resolveTypegenConfig)(finalConfig);
yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema);
yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives);
(0, utils_1.assertNoMissingTypes)(schema, missingTypes);

@@ -75,5 +77,5 @@ (0, utils_1.runAbstractTypeRuntimeChecks)(schema, finalConfig.features);

generateSchema.withArtifacts = (config, typegen = null) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = (0, builder_1.makeSchemaInternal)(config);
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config);
const typegenConfig = (0, typegenUtils_1.resolveTypegenConfig)(finalConfig);
const { schemaTypes, tsTypes, globalTypes } = yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifactContents(schema, typegen);
const { schemaTypes, tsTypes, globalTypes } = yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifactContents(schema, typegen, hasSDLDirectives);
(0, utils_1.assertNoMissingTypes)(schema, missingTypes);

@@ -83,2 +85,40 @@ (0, utils_1.runAbstractTypeRuntimeChecks)(schema, finalConfig.features);

});
/** Builds the schema, we may return more than just the schema from this one day. */
function makeSchemaInternal(config) {
const builder = new builder_1.SchemaBuilder(config);
builder.addTypes(config.types);
builder.addTypes(config.directives);
if (config.schemaRoots) {
builder.addTypes(config.schemaRoots);
}
function getRootType(rootType, defaultType) {
var _a, _b;
const rootTypeVal = (_b = (_a = config.schemaRoots) === null || _a === void 0 ? void 0 : _a[rootType]) !== null && _b !== void 0 ? _b : defaultType;
let returnVal = null;
if (typeof rootTypeVal === 'string') {
returnVal = typeMap[rootTypeVal];
}
else if (rootTypeVal) {
if ((0, wrapping_1.isNexusObjectTypeDef)(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
else if ((0, graphql_1.isObjectType)(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name];
}
}
if (returnVal && !(0, graphql_1.isObjectType)(returnVal)) {
throw new Error(`Expected ${rootType} to be a objectType, saw ${returnVal.constructor.name}`);
}
return returnVal;
}
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns, customDirectives, schemaDirectives, hasSDLDirectives, } = builder.getFinalTypeMap();
const schema = new graphql_1.GraphQLSchema(Object.assign(Object.assign(Object.assign({}, extractGraphQLSchemaOptions(config)), { query: getRootType('query', 'Query'), mutation: getRootType('mutation', 'Mutation'), subscription: getRootType('subscription', 'Subscription'), types: (0, utils_1.objValues)(typeMap), extensions: Object.assign(Object.assign({}, config.extensions), { nexus: schemaExtension }), directives: [...graphql_1.specifiedDirectives, ...Object.values(customDirectives)] }), schemaDirectives));
onAfterBuildFns.forEach((fn) => fn(schema));
return { schema, missingTypes, finalConfig, hasSDLDirectives };
}
exports.makeSchemaInternal = makeSchemaInternal;
function extractGraphQLSchemaOptions(config) {
const { formatTypegen, nonNullDefaults, mergeSchema, outputs, shouldExitAfterGenerateArtifacts, shouldGenerateArtifacts, schemaRoots, sourceTypes, prettierConfig, plugins, customPrintSchemaFn, features, contextType } = config, graphqlConfigOpts = (0, tslib_1.__rest)(config, ["formatTypegen", "nonNullDefaults", "mergeSchema", "outputs", "shouldExitAfterGenerateArtifacts", "shouldGenerateArtifacts", "schemaRoots", "sourceTypes", "prettierConfig", "plugins", "customPrintSchemaFn", "features", "contextType"]);
return graphqlConfigOpts;
}
//# sourceMappingURL=makeSchema.js.map

@@ -20,4 +20,4 @@ import { GraphQLSchema } from 'graphql';

/** Generates the artifacts of the build based on what we know about the schema and how it was defined. */
generateArtifacts(schema: NexusGraphQLSchema): Promise<void>;
generateArtifactContents(schema: NexusGraphQLSchema, typegen: string | null | ConfiguredTypegen): Promise<{
generateArtifacts(schema: NexusGraphQLSchema, hasSDLDirectives: boolean): Promise<void>;
generateArtifactContents(schema: NexusGraphQLSchema, typegen: string | null | ConfiguredTypegen, hasSDLDirectives: boolean): Promise<{
schemaTypes: string;

@@ -30,3 +30,3 @@ tsTypes: string;

/** Generates the schema, adding any directives as necessary */
generateSchemaFile(schema: GraphQLSchema): string;
generateSchemaFile(schema: GraphQLSchema, hasSDLDirectives: boolean): string;
/** Generates the type definitions */

@@ -33,0 +33,0 @@ generateTypesFile(schema: NexusGraphQLSchema, typegenPath: string): Promise<string>;

@@ -8,2 +8,3 @@ "use strict";

const lang_1 = require("./lang");
const printSchemaWithDirectives_1 = require("./printSchemaWithDirectives");
const typegenAutoConfig_1 = require("./typegenAutoConfig");

@@ -21,3 +22,3 @@ const typegenFormatPrettier_1 = require("./typegenFormatPrettier");

/** Generates the artifacts of the build based on what we know about the schema and how it was defined. */
generateArtifacts(schema) {
generateArtifacts(schema, hasSDLDirectives) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {

@@ -27,3 +28,3 @@ const sortedSchema = this.sortSchema(schema);

if (this.config.outputs.schema || typegen) {
const { schemaTypes, tsTypes, globalTypes } = yield this.generateArtifactContents(sortedSchema, typegen);
const { schemaTypes, tsTypes, globalTypes } = yield this.generateArtifactContents(sortedSchema, typegen, hasSDLDirectives);
if (this.config.outputs.schema) {

@@ -46,6 +47,6 @@ yield this.writeFile('schema', schemaTypes, this.config.outputs.schema);

}
generateArtifactContents(schema, typegen) {
generateArtifactContents(schema, typegen, hasSDLDirectives) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
const result = {
schemaTypes: this.generateSchemaFile(schema),
schemaTypes: this.generateSchemaFile(schema, hasSDLDirectives),
tsTypes: '',

@@ -120,6 +121,7 @@ globalTypes: null,

/** Generates the schema, adding any directives as necessary */
generateSchemaFile(schema) {
generateSchemaFile(schema, hasSDLDirectives) {
const printer = hasSDLDirectives ? printSchemaWithDirectives_1.printSchemaWithDirectives : graphql_1.printSchema;
let printedSchema = this.config.customPrintSchemaFn
? this.config.customPrintSchemaFn(schema)
: (0, graphql_1.printSchema)(schema);
: printer(schema);
return [lang_1.SDL_HEADER, printedSchema].join('\n\n');

@@ -126,0 +128,0 @@ }

@@ -38,2 +38,3 @@ import type { TypegenInfo } from './builder';

private printHeadersCommon;
private printDirectives;
private printHeadersGlobal;

@@ -40,0 +41,0 @@ private printGenTypeMap;

@@ -6,2 +6,3 @@ "use strict";

const graphql_1 = require("graphql");
const directive_1 = require("./definitions/directive");
const wrapping_1 = require("./definitions/wrapping");

@@ -87,2 +88,3 @@ const lang_1 = require("./lang");

this.printTypeNames('union', 'NexusGenUnionNames', 'NexusGenUnions'),
this.printDirectives(),
this.printIsTypeOfObjectTypeNames('NexusGenObjectsUsingAbstractStrategyIsTypeOf'),

@@ -104,2 +106,38 @@ this.printResolveTypeAbstractTypes('NexusGenAbstractsUsingStrategyResolveType'),

}
printDirectives() {
const customDirectives = this.schema.getDirectives().filter((d) => !(0, graphql_1.isSpecifiedDirective)(d));
const schemaDirectiveArgs = {};
// Gather the mappings between directives, locations, etc.
customDirectives.forEach((d) => {
d.locations.forEach((l) => {
var _a;
if (directive_1.SchemaDirectiveLocation.includes(l)) {
schemaDirectiveArgs[d.name] = (_a = d.args) !== null && _a !== void 0 ? _a : undefined;
}
});
});
const directiveNames = Object.keys(schemaDirectiveArgs)
.map((i) => JSON.stringify(i))
.join(' | ');
const toPrint = [`export type NexusGenDirectives = ${directiveNames || 'never'}`];
// Print the mappings of the directive names -> args
// NexusGenDirectiveArgs
let directiveArgs = [`export interface NexusGenDirectiveArgs {`];
(0, utils_1.eachObj)(schemaDirectiveArgs, (val, key) => {
if (val) {
directiveArgs.push(` ${key}: {`);
val.forEach((arg) => {
const [sep, rep] = this.normalizeArg(arg);
directiveArgs.push(` ${arg.name}${sep}${rep}`);
});
directiveArgs.push(` }`);
}
else {
directiveArgs.push(` ${key}: never`);
}
});
directiveArgs.push('}');
toPrint.push(directiveArgs.join('\n'));
return toPrint.join('\n\n');
}
printHeadersGlobal() {

@@ -125,2 +163,4 @@ var _a, _b;

` inputTypes: NexusGenInputs;`,
` directives: NexusGenDirectives;`,
` directiveArgs: NexusGenDirectiveArgs;`,
` rootTypes: NexusGenRootTypes;`,

@@ -127,0 +167,0 @@ ` inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars;`,

@@ -106,11 +106,11 @@ import type { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql';

/** Generated type helpers: */
export declare type GenTypesShapeKeys = 'context' | 'inputTypes' | 'rootTypes' | 'inputTypeShapes' | 'argTypes' | 'fieldTypes' | 'fieldTypeNames' | 'allTypes' | 'typeInterfaces' | 'objectNames' | 'inputNames' | 'enumNames' | 'interfaceNames' | 'scalarNames' | 'unionNames' | 'allInputTypes' | 'allOutputTypes' | 'allNamedTypes' | 'abstractTypes' | 'abstractTypeMembers' | 'objectsUsingAbstractStrategyIsTypeOf' | 'abstractsUsingStrategyResolveType' | 'features';
export declare type GenTypesShapeKeys = 'context' | 'inputTypes' | 'rootTypes' | 'inputTypeShapes' | 'directives' | 'directiveArgs' | 'argTypes' | 'fieldTypes' | 'fieldTypeNames' | 'allTypes' | 'typeInterfaces' | 'objectNames' | 'inputNames' | 'enumNames' | 'interfaceNames' | 'scalarNames' | 'unionNames' | 'allInputTypes' | 'allOutputTypes' | 'allNamedTypes' | 'abstractTypes' | 'abstractTypeMembers' | 'objectsUsingAbstractStrategyIsTypeOf' | 'abstractsUsingStrategyResolveType' | 'features';
/** Helpers for handling the generated schema */
export declare type GenTypesShape = Record<GenTypesShapeKeys, any>;
export declare type GetGen<K extends GenTypesShapeKeys, Fallback = any> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? GenTypes[K] : Fallback : Fallback;
export declare type GetGen<K extends GenTypesShapeKeys, Fallback = any> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? GenTypes[K] : Fallback : Fallback;
export declare type GetGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, Fallback = any> = K2 extends keyof GetGen<K, never> ? GetGen<K>[K2] : Fallback;
export declare type GetGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>, Fallback = any> = K2 extends keyof GetGen<K, never> ? K3 extends keyof GetGen<K>[K2] ? GetGen<K>[K2][K3] : Fallback : Fallback;
export declare type HasGen<K extends GenTypesShapeKeys> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? true : false : false : false;
export declare type HasGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? true : false : false : false : false;
export declare type HasGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>> = NexusGen extends infer GenTypes ? GenTypes extends GenTypesShape ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? K3 extends keyof GenTypes[K][K2] ? true : false : false : false : false : false;
export declare type HasGen<K extends GenTypesShapeKeys> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? true : false : false;
export declare type HasGen2<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? true : false : false : false;
export declare type HasGen3<K extends GenTypesShapeKeys, K2 extends Extract<keyof GenTypesShape[K], string>, K3 extends Extract<keyof GenTypesShape[K][K2], string>> = NexusGen extends infer GenTypes ? K extends keyof GenTypes ? K2 extends keyof GenTypes[K] ? K3 extends keyof GenTypes[K][K2] ? true : false : false : false : false;
export declare type SourceValue<TypeName extends string> = GetGen2<'rootTypes', TypeName>;

@@ -117,0 +117,0 @@ export declare type RootValueField<TypeName extends string, FieldName extends string> = GetGen3<'rootTypes', TypeName, FieldName>;

@@ -40,2 +40,3 @@ /**

export declare type UnwrapPromise<R> = R extends PromiseLike<infer U> ? U : R;
export declare type MaybeReadonlyArray<T> = Array<T> | ReadonlyArray<T>;
export {};
{
"name": "nexus",
"version": "1.4.0-next.6",
"version": "1.4.0-next.7",
"description": "Scalable, strongly typed GraphQL schema development",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,2 +6,3 @@ // The "core" is used as a namespace to re-export everything,

export * from './definitions/args'
export * from './definitions/directive'
export * from './definitions/decorateType'

@@ -8,0 +9,0 @@ export * from './definitions/definitionBlocks'

@@ -16,2 +16,3 @@ import type {

} from 'graphql'
import type { NexusDirectiveConfig } from '../core'
import type {

@@ -57,2 +58,4 @@ NexusFieldExtension,

Union = 'Union',
Directive = 'Directive',
DirectiveUse = 'DirectiveUse',
}

@@ -160,2 +163,4 @@

export type NexusGraphQLDirectiveConfig = WithExt<NexusDirectiveConfig, NexusInputObjectTypeExtension>
export interface NexusGraphQLSchema extends GraphQLSchema {

@@ -162,0 +167,0 @@ extensions: {

import type { GraphQLScalarTypeConfig } from 'graphql'
import type { AllInputTypes, GetGen2 } from '../typegenTypeHelpers'
import type { Directives } from './directive'
import type { AllNexusArgsDefs, AllNexusInputTypeDefs } from './wrapping'

@@ -50,2 +51,9 @@ import { Maybe, NexusTypes, withNexusSymbol } from './_types'

extensions?: GraphQLScalarTypeConfig<any, any>['extensions']
/**
* A list of directives / directive uses (with args) for the arg definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
} & NexusGenPluginArgConfig

@@ -52,0 +60,0 @@

@@ -12,2 +12,3 @@ import type { GraphQLFieldConfig, GraphQLFieldResolver, GraphQLInputFieldConfig } from 'graphql'

import type { ArgsRecord } from './args'
import type { Directives } from './directive'
import type { NexusMetaType } from './nexusMeta'

@@ -107,2 +108,9 @@ import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs, NexusWrapKind } from './wrapping'

extensions?: GraphQLFieldConfig<any, any>['extensions']
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
} & NexusGenPluginFieldConfig<TypeName, FieldName>

@@ -119,4 +127,12 @@

extensions?: GraphQLInputFieldConfig['extensions']
/**
* A list of directives / directive uses (with args) for the input field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
} & NexusGenPluginFieldConfig<TypeName, FieldName> &
NexusGenPluginInputFieldConfig<TypeName, FieldName>
export interface OutputScalarConfig<TypeName extends string, FieldName extends string>

@@ -123,0 +139,0 @@ extends CommonOutputFieldConfig<TypeName, FieldName> {

import { assertValidName, GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql'
import { arg, NexusArgDef, NexusAsArgConfig } from './args'
import type { Directives } from './directive'
import { Maybe, NexusTypes, SourceTypingDef, withNexusSymbol } from './_types'

@@ -27,2 +28,9 @@

extensions?: GraphQLEnumValueConfig['extensions']
/**
* A list of directives / directive uses (with args) for the enum member definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
}

@@ -47,2 +55,9 @@

extensions?: GraphQLEnumTypeConfig['extensions']
/**
* A list of directives / directive uses (with args) for the enum type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -49,0 +64,0 @@ asNexusMethod?: string

import { assertValidName, GraphQLInputObjectTypeConfig } from 'graphql'
import { arg, NexusArgDef, NexusAsArgConfig } from './args'
import type { InputDefinitionBlock } from './definitionBlocks'
import type { Directives } from './directive'
import { Maybe, NexusTypes, NonNullConfig, withNexusSymbol } from './_types'

@@ -24,2 +25,9 @@

extensions?: GraphQLInputObjectTypeConfig['extensions']
/**
* A list of directives / directive uses (with args) for the input object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -26,0 +34,0 @@ asNexusMethod?: string

@@ -5,2 +5,3 @@ import { assertValidName, GraphQLInterfaceTypeConfig } from 'graphql'

import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks'
import type { Directives } from './directive'
import { AbstractTypes, Maybe, NexusTypes, NonNullConfig, SourceTypingDef, withNexusSymbol } from './_types'

@@ -57,2 +58,9 @@

extensions?: GraphQLInterfaceTypeConfig<any, any>['extensions']
/**
* A list of directives / directive uses (with args) for the output field definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -59,0 +67,0 @@ asNexusMethod?: string

import { assertValidName, GraphQLObjectType } from 'graphql'
import type { InterfaceFieldsFor } from '../typegenTypeHelpers'
import { OutputDefinitionBlock, OutputDefinitionBuilder } from './definitionBlocks'
import type { Directives } from './directive'
import type { FieldModification, FieldModificationDef, Implemented } from './interfaceType'

@@ -192,2 +193,9 @@ import { AbstractTypes, Maybe, NexusTypes, NonNullConfig, SourceTypingDef, withNexusSymbol } from './_types'

definition(t: ObjectDefinitionBlock<TypeName>): void
/**
* A list of directives / directive uses (with args) for the object type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -194,0 +202,0 @@ asNexusMethod?: string

import { assertValidName, GraphQLNamedType, GraphQLScalarTypeConfig } from 'graphql'
import type { AllNexusInputTypeDefs, AllNexusOutputTypeDefs } from '../core'
import { decorateType } from './decorateType'
import type { Directives } from './directive'
import { GraphQLNamedOutputType, Maybe, NexusTypes, SourceTypingDef, withNexusSymbol } from './_types'

@@ -25,2 +26,9 @@

extensions?: GraphQLScalarTypeConfig<any, any>['extensions']
/**
* A list of directives / directive uses (with args) for the scalar type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
}

@@ -27,0 +35,0 @@

import { assertValidName, GraphQLUnionTypeConfig } from 'graphql'
import type { Directives } from '../core'
import type { GetGen } from '../typegenTypeHelpers'

@@ -44,2 +45,9 @@ import type { NexusObjectTypeDef } from './objectType'

extensions?: GraphQLUnionTypeConfig<any, any>['extensions']
/**
* A list of directives / directive uses (with args) for the union type definition
*
* @example
* directives: [addDirective('ExampleDirective', { arg: true })]
*/
directives?: Directives
/** Adds this type as a method on the Object/Interface definition blocks */

@@ -46,0 +54,0 @@ asNexusMethod?: string

@@ -30,2 +30,4 @@ import {

import { NexusTypes, NexusWrappedSymbol } from './_types'
import type { NexusDirectiveDef } from './directive'
import type { NexusDirectiveUse } from '../core'

@@ -210,2 +212,9 @@ /** Input(named): Nexus only */

export function isNexusDirective(obj: any): obj is NexusDirectiveDef {
return isNexusStruct(obj) && obj[NexusWrappedSymbol] === NexusTypes.Directive
}
export function isNexusDirectiveUse(obj: any): obj is NexusDirectiveUse {
return isNexusStruct(obj) && obj[NexusWrappedSymbol] === NexusTypes.DirectiveUse
}
export type NexusWrapKind = 'NonNull' | 'Null' | 'List'

@@ -212,0 +221,0 @@ export type NexusFinalWrapKind = 'NonNull' | 'List'

@@ -8,2 +8,3 @@ import { defaultFieldResolver, GraphQLNamedType } from 'graphql'

import type { NexusObjectTypeConfig } from './definitions/objectType'
import type { Directives } from './core'

@@ -71,2 +72,3 @@ /** @internal */

sourceTypings: SourceTypings
schemaDirectives?: Directives
}

@@ -73,0 +75,0 @@

@@ -7,2 +7,3 @@ import * as blocks from './blocks'

export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args'
export { directive, addDirective } from './definitions/directive'
export { decorateType } from './definitions/decorateType'

@@ -9,0 +10,0 @@ export { enumType } from './definitions/enumType'

@@ -1,6 +0,14 @@

import { ConfiguredTypegen, makeSchemaInternal, SchemaConfig } from './builder'
import { GraphQLNamedType, GraphQLSchema, isObjectType, specifiedDirectives } from 'graphql'
import { isNexusObjectTypeDef } from './definitions/wrapping'
import {
AdditionalGraphQLSchemaConfigOptions,
ConfiguredTypegen,
MakeSchemaOptions,
SchemaBuilder,
SchemaConfig,
} from './builder'
import type { NexusGraphQLSchema } from './definitions/_types'
import { TypegenMetadata } from './typegenMetadata'
import { resolveTypegenConfig } from './typegenUtils'
import { assertNoMissingTypes, runAbstractTypeRuntimeChecks } from './utils'
import { assertNoMissingTypes, objValues, runAbstractTypeRuntimeChecks } from './utils'

@@ -14,3 +22,3 @@ /**

export function makeSchema(config: SchemaConfig): NexusGraphQLSchema {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)

@@ -22,3 +30,3 @@ const sdl = typegenConfig.outputs.schema

// in the optional thunk for the typegen config
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema)
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives)
if (config.shouldExitAfterGenerateArtifacts) {

@@ -56,5 +64,5 @@ let typegenPath = '(not enabled)'

export async function generateSchema(config: SchemaConfig): Promise<NexusGraphQLSchema> {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)
await new TypegenMetadata(typegenConfig).generateArtifacts(schema)
await new TypegenMetadata(typegenConfig).generateArtifacts(schema, hasSDLDirectives)
assertNoMissingTypes(schema, missingTypes)

@@ -78,7 +86,7 @@ runAbstractTypeRuntimeChecks(schema, finalConfig.features)

}> => {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const { schema, missingTypes, finalConfig, hasSDLDirectives } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)
const { schemaTypes, tsTypes, globalTypes } = await new TypegenMetadata(
typegenConfig
).generateArtifactContents(schema, typegen)
).generateArtifactContents(schema, typegen, hasSDLDirectives)
assertNoMissingTypes(schema, missingTypes)

@@ -88,1 +96,82 @@ runAbstractTypeRuntimeChecks(schema, finalConfig.features)

}
/** Builds the schema, we may return more than just the schema from this one day. */
export function makeSchemaInternal(config: SchemaConfig) {
const builder = new SchemaBuilder(config)
builder.addTypes(config.types)
builder.addTypes(config.directives)
if (config.schemaRoots) {
builder.addTypes(config.schemaRoots)
}
function getRootType(rootType: 'query' | 'mutation' | 'subscription', defaultType: string) {
const rootTypeVal = config.schemaRoots?.[rootType] ?? defaultType
let returnVal: null | GraphQLNamedType = null
if (typeof rootTypeVal === 'string') {
returnVal = typeMap[rootTypeVal]
} else if (rootTypeVal) {
if (isNexusObjectTypeDef(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name]
} else if (isObjectType(rootTypeVal)) {
returnVal = typeMap[rootTypeVal.name]
}
}
if (returnVal && !isObjectType(returnVal)) {
throw new Error(`Expected ${rootType} to be a objectType, saw ${returnVal.constructor.name}`)
}
return returnVal
}
const {
finalConfig,
typeMap,
missingTypes,
schemaExtension,
onAfterBuildFns,
customDirectives,
schemaDirectives,
hasSDLDirectives,
} = builder.getFinalTypeMap()
const schema = new GraphQLSchema({
...extractGraphQLSchemaOptions(config),
query: getRootType('query', 'Query'),
mutation: getRootType('mutation', 'Mutation'),
subscription: getRootType('subscription', 'Subscription'),
types: objValues(typeMap),
extensions: {
...config.extensions,
nexus: schemaExtension,
},
directives: [...specifiedDirectives, ...Object.values(customDirectives)],
...schemaDirectives,
}) as NexusGraphQLSchema
onAfterBuildFns.forEach((fn) => fn(schema))
return { schema, missingTypes, finalConfig, hasSDLDirectives }
}
type OmittedVals = Partial<{ [K in keyof MakeSchemaOptions]: never }>
function extractGraphQLSchemaOptions(
config: SchemaConfig
): Partial<AdditionalGraphQLSchemaConfigOptions & OmittedVals> {
const {
formatTypegen,
nonNullDefaults,
mergeSchema,
outputs,
shouldExitAfterGenerateArtifacts,
shouldGenerateArtifacts,
schemaRoots,
sourceTypes,
prettierConfig,
plugins,
customPrintSchemaFn,
features,
contextType,
...graphqlConfigOpts
} = config
return graphqlConfigOpts
}

@@ -7,2 +7,3 @@ import { GraphQLSchema, lexicographicSortSchema, printSchema } from 'graphql'

import { SDL_HEADER, TYPEGEN_HEADER } from './lang'
import { printSchemaWithDirectives } from './printSchemaWithDirectives'
import { typegenAutoConfig } from './typegenAutoConfig'

@@ -29,7 +30,11 @@ import { typegenFormatPrettier } from './typegenFormatPrettier'

/** Generates the artifacts of the build based on what we know about the schema and how it was defined. */
async generateArtifacts(schema: NexusGraphQLSchema) {
async generateArtifacts(schema: NexusGraphQLSchema, hasSDLDirectives: boolean) {
const sortedSchema = this.sortSchema(schema)
const { typegen } = this.config.outputs
if (this.config.outputs.schema || typegen) {
const { schemaTypes, tsTypes, globalTypes } = await this.generateArtifactContents(sortedSchema, typegen)
const { schemaTypes, tsTypes, globalTypes } = await this.generateArtifactContents(
sortedSchema,
typegen,
hasSDLDirectives
)
if (this.config.outputs.schema) {

@@ -51,5 +56,9 @@ await this.writeFile('schema', schemaTypes, this.config.outputs.schema)

async generateArtifactContents(schema: NexusGraphQLSchema, typegen: string | null | ConfiguredTypegen) {
async generateArtifactContents(
schema: NexusGraphQLSchema,
typegen: string | null | ConfiguredTypegen,
hasSDLDirectives: boolean
) {
const result = {
schemaTypes: this.generateSchemaFile(schema),
schemaTypes: this.generateSchemaFile(schema, hasSDLDirectives),
tsTypes: '',

@@ -125,6 +134,7 @@ globalTypes: null as null | string,

/** Generates the schema, adding any directives as necessary */
generateSchemaFile(schema: GraphQLSchema): string {
generateSchemaFile(schema: GraphQLSchema, hasSDLDirectives: boolean): string {
const printer = hasSDLDirectives ? printSchemaWithDirectives : printSchema
let printedSchema = this.config.customPrintSchemaFn
? this.config.customPrintSchemaFn(schema)
: printSchema(schema)
: printer(schema)
return [SDL_HEADER, printedSchema].join('\n\n')

@@ -131,0 +141,0 @@ }

@@ -21,2 +21,3 @@ import {

isScalarType,
isSpecifiedDirective,
isSpecifiedScalarType,

@@ -26,2 +27,3 @@ isUnionType,

import type { TypegenInfo } from './builder'
import { SchemaDirectiveLocation } from './definitions/directive'
import { isNexusPrintedGenTyping, isNexusPrintedGenTypingImport } from './definitions/wrapping'

@@ -134,2 +136,3 @@ import type { NexusGraphQLSchema } from './definitions/_types'

this.printTypeNames('union', 'NexusGenUnionNames', 'NexusGenUnions'),
this.printDirectives(),
this.printIsTypeOfObjectTypeNames('NexusGenObjectsUsingAbstractStrategyIsTypeOf'),

@@ -154,2 +157,45 @@ this.printResolveTypeAbstractTypes('NexusGenAbstractsUsingStrategyResolveType'),

private printDirectives() {
const customDirectives = this.schema.getDirectives().filter((d) => !isSpecifiedDirective(d))
const schemaDirectiveArgs: Record<string, readonly GraphQLArgument[] | undefined> = {}
// Gather the mappings between directives, locations, etc.
customDirectives.forEach((d) => {
d.locations.forEach((l) => {
if (SchemaDirectiveLocation.includes(l as any)) {
schemaDirectiveArgs[d.name] = d.args ?? undefined
}
})
})
const directiveNames = Object.keys(schemaDirectiveArgs)
.map((i) => JSON.stringify(i))
.join(' | ')
const toPrint: string[] = [`export type NexusGenDirectives = ${directiveNames || 'never'}`]
// Print the mappings of the directive names -> args
// NexusGenDirectiveArgs
let directiveArgs = [`export interface NexusGenDirectiveArgs {`]
eachObj(schemaDirectiveArgs, (val, key) => {
if (val) {
directiveArgs.push(` ${key}: {`)
val.forEach((arg) => {
const [sep, rep] = this.normalizeArg(arg)
directiveArgs.push(` ${arg.name}${sep}${rep}`)
})
directiveArgs.push(` }`)
} else {
directiveArgs.push(` ${key}: never`)
}
})
directiveArgs.push('}')
toPrint.push(directiveArgs.join('\n'))
return toPrint.join('\n\n')
}
private printHeadersGlobal() {

@@ -182,2 +228,4 @@ const headers = [

` inputTypes: NexusGenInputs;`,
` directives: NexusGenDirectives;`,
` directiveArgs: NexusGenDirectiveArgs;`,
` rootTypes: NexusGenRootTypes;`,

@@ -184,0 +232,0 @@ ` inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars;`,

@@ -158,2 +158,4 @@ import type { GraphQLAbstractType, GraphQLResolveInfo } from 'graphql'

| 'inputTypeShapes'
| 'directives'
| 'directiveArgs'
| 'argTypes'

@@ -183,3 +185,3 @@ | 'fieldTypes'

export type GetGen<K extends GenTypesShapeKeys, Fallback = any> = NexusGen extends infer GenTypes
? GenTypes extends GenTypesShape
? K extends keyof GenTypes
? GenTypes[K]

@@ -207,6 +209,4 @@ : Fallback

export type HasGen<K extends GenTypesShapeKeys> = NexusGen extends infer GenTypes
? GenTypes extends GenTypesShape
? K extends keyof GenTypes
? true
: false
? K extends keyof GenTypes
? true
: false

@@ -219,7 +219,5 @@ : false

> = NexusGen extends infer GenTypes
? GenTypes extends GenTypesShape
? K extends keyof GenTypes
? K2 extends keyof GenTypes[K]
? true
: false
? K extends keyof GenTypes
? K2 extends keyof GenTypes[K]
? true
: false

@@ -234,8 +232,6 @@ : false

> = NexusGen extends infer GenTypes
? GenTypes extends GenTypesShape
? K extends keyof GenTypes
? K2 extends keyof GenTypes[K]
? K3 extends keyof GenTypes[K][K2]
? true
: false
? K extends keyof GenTypes
? K2 extends keyof GenTypes[K]
? K3 extends keyof GenTypes[K][K2]
? true
: false

@@ -242,0 +238,0 @@ : false

@@ -59,1 +59,3 @@ /**

export type UnwrapPromise<R> = R extends PromiseLike<infer U> ? U : R
export type MaybeReadonlyArray<T> = Array<T> | ReadonlyArray<T>

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

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

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

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

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 too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc