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.1.0-next.16 to 1.1.0-next.17

dist-esm/makeSchema.d.ts

16

dist-esm/builder.d.ts

@@ -314,18 +314,2 @@ import { GraphQLField, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLObjectType, GraphQLOutputType, GraphQLSchemaConfig, GraphQLType, printSchema } from 'graphql';

export declare function setConfigDefaults(config: BuilderConfigInput): BuilderConfig;
/**
* Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any
* manually defined GraphQLType objects.
*
* Requires at least one type be named "Query", which will be used as the root query type.
*/
export declare function makeSchema(config: SchemaConfig): NexusGraphQLSchema;
/** Like makeSchema except that typegen is always run and waited upon. */
export declare function generateSchema(config: SchemaConfig): Promise<NexusGraphQLSchema>;
export declare namespace generateSchema {
var withArtifacts: (config: SchemaConfig, typeFilePath?: string | null) => Promise<{
schema: NexusGraphQLSchema;
schemaTypes: string;
tsTypes: string;
}>;
}
export {};

69

dist-esm/builder.js

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

import { __awaiter, __rest } from "tslib";
import { __rest } from "tslib";
import { assertValidName, defaultFieldResolver, getNamedType, GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLInterfaceType, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLString, GraphQLUnionType, isInputObjectType, isInterfaceType, isLeafType, isNamedType, isObjectType, isOutputType, isScalarType, isSchema, isUnionType, isWrappingType, } from 'graphql';

@@ -13,5 +13,3 @@ import { InputDefinitionBlock, } from './definitions/definitionBlocks';

import { fieldAuthorizePlugin } from './plugins/fieldAuthorizePlugin';
import { TypegenMetadata } from './typegenMetadata';
import { resolveTypegenConfig } from './typegenUtils';
import { assertNoMissingTypes, casesHandled, consoleWarn, eachObj, getArgNamedType, getNexusNamedType, graphql15InterfaceConfig, graphql15InterfaceType, invariantGuard, isObject, mapValues, objValues, runAbstractTypeRuntimeChecks, UNKNOWN_TYPE_SCALAR, } from './utils';
import { casesHandled, consoleWarn, eachObj, getArgNamedType, getNexusNamedType, graphql15InterfaceConfig, graphql15InterfaceType, invariantGuard, isArray, isObject, mapValues, objValues, UNKNOWN_TYPE_SCALAR, } from './utils';
const SCALARS = {

@@ -543,3 +541,3 @@ String: GraphQLString,

const values = {};
if (Array.isArray(members)) {
if (isArray(members)) {
members.forEach((m) => {

@@ -1149,63 +1147,2 @@ var _a, _b;

}
/**
* Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any
* manually defined GraphQLType objects.
*
* Requires at least one type be named "Query", which will be used as the root query type.
*/
export function makeSchema(config) {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);
const sdl = typegenConfig.outputs.schema;
const typegen = typegenConfig.outputs.typegen;
if (sdl || typegen) {
// Generating in the next tick allows us to use the schema
// in the optional thunk for the typegen config
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema);
if (config.shouldExitAfterGenerateArtifacts) {
typegenPromise
.then(() => {
console.log(`Generated Artifacts:
TypeScript Types ==> ${typegenConfig.outputs.typegen || '(not enabled)'}
GraphQL Schema ==> ${typegenConfig.outputs.schema || '(not enabled)'}`);
process.exit(0);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
}
else {
typegenPromise.catch((e) => {
console.error(e);
});
}
}
assertNoMissingTypes(schema, missingTypes);
runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return schema;
}
/** Like makeSchema except that typegen is always run and waited upon. */
export function generateSchema(config) {
return __awaiter(this, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);
yield new TypegenMetadata(typegenConfig).generateArtifacts(schema);
assertNoMissingTypes(schema, missingTypes);
runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return schema;
});
}
/**
* Mainly useful for testing, generates the schema and returns the artifacts that would have been otherwise
* written to the filesystem.
*/
generateSchema.withArtifacts = (config, typeFilePath = null) => __awaiter(void 0, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = resolveTypegenConfig(finalConfig);
const { schemaTypes, tsTypes } = yield new TypegenMetadata(typegenConfig).generateArtifactContents(schema, typeFilePath);
assertNoMissingTypes(schema, missingTypes);
runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return { schema, schemaTypes, tsTypes };
});
//# sourceMappingURL=builder.js.map
export * from './builder';
export * from './makeSchema';
export * from './definitions/args';

@@ -3,0 +4,0 @@ export * from './definitions/decorateType';

// The "core" is used as a namespace to re-export everything,
// For anyone who wants to use the internals
export * from './builder';
export * from './makeSchema';
export * from './definitions/args';

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

@@ -33,3 +33,3 @@ import { GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql';

/** All members of the enum, either as an array of strings/definition objects, as an object, or as a TypeScript enum */
members: Array<string | EnumMemberInfo> | Record<string, string | number | object | boolean> | TypeScriptEnumLike;
members: ReadonlyArray<string | EnumMemberInfo> | Record<string, string | number | object | boolean> | TypeScriptEnumLike;
/**

@@ -36,0 +36,0 @@ * Custom extensions, as supported in graphql-js

import * as blocks from './blocks';
import * as core from './core';
export { makeSchema } from './builder';
export { makeSchema } from './makeSchema';
export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';

@@ -5,0 +5,0 @@ export { decorateType } from './definitions/decorateType';

import * as blocks from './blocks';
import * as core from './core';
// All of the Public API definitions
export { makeSchema } from './builder';
export { makeSchema } from './makeSchema';
export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';

@@ -6,0 +6,0 @@ export { decorateType } from './definitions/decorateType';

@@ -109,1 +109,6 @@ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLNamedType, GraphQLObjectType, GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema, GraphQLType, GraphQLUnionType } from 'graphql';

};
/**
* A specially typed version of `Array.isArray` to work around [this
* issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
export declare function isArray<T>(arg: T | {}): arg is T extends readonly any[] ? (unknown extends T ? never : readonly any[]) : any[];

@@ -459,2 +459,9 @@ import * as fs from 'fs';

}
/**
* A specially typed version of `Array.isArray` to work around [this
* issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
export function isArray(arg) {
return Array.isArray(arg);
}
//# sourceMappingURL=utils.js.map

@@ -314,18 +314,2 @@ import { GraphQLField, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLObjectType, GraphQLOutputType, GraphQLSchemaConfig, GraphQLType, printSchema } from 'graphql';

export declare function setConfigDefaults(config: BuilderConfigInput): BuilderConfig;
/**
* Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any
* manually defined GraphQLType objects.
*
* Requires at least one type be named "Query", which will be used as the root query type.
*/
export declare function makeSchema(config: SchemaConfig): NexusGraphQLSchema;
/** Like makeSchema except that typegen is always run and waited upon. */
export declare function generateSchema(config: SchemaConfig): Promise<NexusGraphQLSchema>;
export declare namespace generateSchema {
var withArtifacts: (config: SchemaConfig, typeFilePath?: string | null) => Promise<{
schema: NexusGraphQLSchema;
schemaTypes: string;
tsTypes: string;
}>;
}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSchema = exports.makeSchema = exports.setConfigDefaults = exports.makeSchemaInternal = exports.SchemaBuilder = void 0;
exports.setConfigDefaults = exports.makeSchemaInternal = exports.SchemaBuilder = void 0;
const tslib_1 = require("tslib");

@@ -16,4 +16,2 @@ const graphql_1 = require("graphql");

const fieldAuthorizePlugin_1 = require("./plugins/fieldAuthorizePlugin");
const typegenMetadata_1 = require("./typegenMetadata");
const typegenUtils_1 = require("./typegenUtils");
const utils_1 = require("./utils");

@@ -546,3 +544,3 @@ const SCALARS = {

const values = {};
if (Array.isArray(members)) {
if (utils_1.isArray(members)) {
members.forEach((m) => {

@@ -1155,65 +1153,2 @@ var _a, _b;

exports.setConfigDefaults = setConfigDefaults;
/**
* Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any
* manually defined GraphQLType objects.
*
* Requires at least one type be named "Query", which will be used as the root query type.
*/
function makeSchema(config) {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = typegenUtils_1.resolveTypegenConfig(finalConfig);
const sdl = typegenConfig.outputs.schema;
const typegen = typegenConfig.outputs.typegen;
if (sdl || typegen) {
// Generating in the next tick allows us to use the schema
// in the optional thunk for the typegen config
const typegenPromise = new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema);
if (config.shouldExitAfterGenerateArtifacts) {
typegenPromise
.then(() => {
console.log(`Generated Artifacts:
TypeScript Types ==> ${typegenConfig.outputs.typegen || '(not enabled)'}
GraphQL Schema ==> ${typegenConfig.outputs.schema || '(not enabled)'}`);
process.exit(0);
})
.catch((e) => {
console.error(e);
process.exit(1);
});
}
else {
typegenPromise.catch((e) => {
console.error(e);
});
}
}
utils_1.assertNoMissingTypes(schema, missingTypes);
utils_1.runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return schema;
}
exports.makeSchema = makeSchema;
/** Like makeSchema except that typegen is always run and waited upon. */
function generateSchema(config) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = typegenUtils_1.resolveTypegenConfig(finalConfig);
yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema);
utils_1.assertNoMissingTypes(schema, missingTypes);
utils_1.runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return schema;
});
}
exports.generateSchema = generateSchema;
/**
* Mainly useful for testing, generates the schema and returns the artifacts that would have been otherwise
* written to the filesystem.
*/
generateSchema.withArtifacts = (config, typeFilePath = null) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config);
const typegenConfig = typegenUtils_1.resolveTypegenConfig(finalConfig);
const { schemaTypes, tsTypes } = yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifactContents(schema, typeFilePath);
utils_1.assertNoMissingTypes(schema, missingTypes);
utils_1.runAbstractTypeRuntimeChecks(schema, finalConfig.features);
return { schema, schemaTypes, tsTypes };
});
//# sourceMappingURL=builder.js.map
export * from './builder';
export * from './makeSchema';
export * from './definitions/args';

@@ -3,0 +4,0 @@ export * from './definitions/decorateType';

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

tslib_1.__exportStar(require("./builder"), exports);
tslib_1.__exportStar(require("./makeSchema"), exports);
tslib_1.__exportStar(require("./definitions/args"), exports);

@@ -9,0 +10,0 @@ tslib_1.__exportStar(require("./definitions/decorateType"), exports);

@@ -33,3 +33,3 @@ import { GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql';

/** All members of the enum, either as an array of strings/definition objects, as an object, or as a TypeScript enum */
members: Array<string | EnumMemberInfo> | Record<string, string | number | object | boolean> | TypeScriptEnumLike;
members: ReadonlyArray<string | EnumMemberInfo> | Record<string, string | number | object | boolean> | TypeScriptEnumLike;
/**

@@ -36,0 +36,0 @@ * Custom extensions, as supported in graphql-js

import * as blocks from './blocks';
import * as core from './core';
export { makeSchema } from './builder';
export { makeSchema } from './makeSchema';
export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args';

@@ -5,0 +5,0 @@ export { decorateType } from './definitions/decorateType';

@@ -10,4 +10,4 @@ "use strict";

// All of the Public API definitions
var builder_1 = require("./builder");
Object.defineProperty(exports, "makeSchema", { enumerable: true, get: function () { return builder_1.makeSchema; } });
var makeSchema_1 = require("./makeSchema");
Object.defineProperty(exports, "makeSchema", { enumerable: true, get: function () { return makeSchema_1.makeSchema; } });
var args_1 = require("./definitions/args");

@@ -14,0 +14,0 @@ Object.defineProperty(exports, "arg", { enumerable: true, get: function () { return args_1.arg; } });

@@ -109,1 +109,6 @@ import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLInterfaceTypeConfig, GraphQLNamedType, GraphQLObjectType, GraphQLResolveInfo, GraphQLScalarType, GraphQLSchema, GraphQLType, GraphQLUnionType } from 'graphql';

};
/**
* A specially typed version of `Array.isArray` to work around [this
* issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
export declare function isArray<T>(arg: T | {}): arg is T extends readonly any[] ? (unknown extends T ? never : readonly any[]) : any[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.graphql15InterfaceType = exports.graphql15InterfaceConfig = exports.Unreachable = exports.raiseProgrammerError = exports.isProductionStage = exports.invariantGuard = exports.getNexusNamedType = exports.getArgNamedType = exports.resolveImportPath = exports.dump = exports.casesHandled = exports.getOwnPackage = exports.pathToArray = exports.UNKNOWN_TYPE_SCALAR = exports.venn = exports.log = exports.consoleWarn = exports.runAbstractTypeRuntimeChecks = exports.assertNoMissingTypes = exports.printedGenTyping = exports.PrintedGenTyping = exports.printedGenTypingImport = exports.PrintedGenTypingImport = exports.relativePathTo = exports.formatPathForModuleImport = exports.typeScriptFileExtension = exports.isPromiseLike = exports.firstDefined = exports.isUnknownType = exports.groupTypes = exports.assertAbsolutePath = exports.isObject = exports.eachObj = exports.mapValues = exports.mapObj = exports.objValues = exports.suggestionList = exports.isInterfaceField = void 0;
exports.isArray = exports.graphql15InterfaceType = exports.graphql15InterfaceConfig = exports.Unreachable = exports.raiseProgrammerError = exports.isProductionStage = exports.invariantGuard = exports.getNexusNamedType = exports.getArgNamedType = exports.resolveImportPath = exports.dump = exports.casesHandled = exports.getOwnPackage = exports.pathToArray = exports.UNKNOWN_TYPE_SCALAR = exports.venn = exports.log = exports.consoleWarn = exports.runAbstractTypeRuntimeChecks = exports.assertNoMissingTypes = exports.printedGenTyping = exports.PrintedGenTyping = exports.printedGenTypingImport = exports.PrintedGenTypingImport = exports.relativePathTo = exports.formatPathForModuleImport = exports.typeScriptFileExtension = exports.isPromiseLike = exports.firstDefined = exports.isUnknownType = exports.groupTypes = exports.assertAbsolutePath = exports.isObject = exports.eachObj = exports.mapValues = exports.mapObj = exports.objValues = exports.suggestionList = exports.isInterfaceField = void 0;
const tslib_1 = require("tslib");

@@ -499,2 +499,10 @@ const fs = tslib_1.__importStar(require("fs"));

exports.graphql15InterfaceType = graphql15InterfaceType;
/**
* A specially typed version of `Array.isArray` to work around [this
* issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
function isArray(arg) {
return Array.isArray(arg);
}
exports.isArray = isArray;
//# sourceMappingURL=utils.js.map
{
"name": "nexus",
"version": "1.1.0-next.16",
"version": "1.1.0-next.17",
"description": "Scalable, strongly typed GraphQL schema development",

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

@@ -128,8 +128,5 @@ import {

import type { TypegenFormatFn } from './typegenFormatPrettier'
import { TypegenMetadata } from './typegenMetadata'
import type { AbstractTypeResolver, GetGen } from './typegenTypeHelpers'
import { resolveTypegenConfig } from './typegenUtils'
import type { RequiredDeeply } from './typeHelpersInternal'
import {
assertNoMissingTypes,
casesHandled,

@@ -143,6 +140,6 @@ consoleWarn,

invariantGuard,
isArray,
isObject,
mapValues,
objValues,
runAbstractTypeRuntimeChecks,
UNKNOWN_TYPE_SCALAR,

@@ -957,3 +954,3 @@ } from './utils'

const values: GraphQLEnumValueConfigMap = {}
if (Array.isArray(members)) {
if (isArray(members)) {
members.forEach((m) => {

@@ -1748,72 +1745,1 @@ if (typeof m === 'string') {

}
/**
* Defines the GraphQL schema, by combining the GraphQL types defined by the GraphQL Nexus layer or any
* manually defined GraphQLType objects.
*
* Requires at least one type be named "Query", which will be used as the root query type.
*/
export function makeSchema(config: SchemaConfig): NexusGraphQLSchema {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)
const sdl = typegenConfig.outputs.schema
const typegen = typegenConfig.outputs.typegen
if (sdl || typegen) {
// Generating in the next tick allows us to use the schema
// in the optional thunk for the typegen config
const typegenPromise = new TypegenMetadata(typegenConfig).generateArtifacts(schema)
if (config.shouldExitAfterGenerateArtifacts) {
typegenPromise
.then(() => {
console.log(`Generated Artifacts:
TypeScript Types ==> ${typegenConfig.outputs.typegen || '(not enabled)'}
GraphQL Schema ==> ${typegenConfig.outputs.schema || '(not enabled)'}`)
process.exit(0)
})
.catch((e) => {
console.error(e)
process.exit(1)
})
} else {
typegenPromise.catch((e) => {
console.error(e)
})
}
}
assertNoMissingTypes(schema, missingTypes)
runAbstractTypeRuntimeChecks(schema, finalConfig.features)
return schema
}
/** Like makeSchema except that typegen is always run and waited upon. */
export async function generateSchema(config: SchemaConfig): Promise<NexusGraphQLSchema> {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)
await new TypegenMetadata(typegenConfig).generateArtifacts(schema)
assertNoMissingTypes(schema, missingTypes)
runAbstractTypeRuntimeChecks(schema, finalConfig.features)
return schema
}
/**
* Mainly useful for testing, generates the schema and returns the artifacts that would have been otherwise
* written to the filesystem.
*/
generateSchema.withArtifacts = async (
config: SchemaConfig,
typeFilePath: string | null = null
): Promise<{
schema: NexusGraphQLSchema
schemaTypes: string
tsTypes: string
}> => {
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config)
const typegenConfig = resolveTypegenConfig(finalConfig)
const { schemaTypes, tsTypes } = await new TypegenMetadata(typegenConfig).generateArtifactContents(
schema,
typeFilePath
)
assertNoMissingTypes(schema, missingTypes)
runAbstractTypeRuntimeChecks(schema, finalConfig.features)
return { schema, schemaTypes, tsTypes }
}
// The "core" is used as a namespace to re-export everything,
// For anyone who wants to use the internals
export * from './builder'
export * from './makeSchema'
export * from './definitions/args'

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

@@ -37,3 +37,3 @@ import { assertValidName, GraphQLEnumTypeConfig, GraphQLEnumValueConfig } from 'graphql'

members:
| Array<string | EnumMemberInfo>
| ReadonlyArray<string | EnumMemberInfo>
| Record<string, string | number | object | boolean>

@@ -40,0 +40,0 @@ | TypeScriptEnumLike

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

// All of the Public API definitions
export { makeSchema } from './builder'
export { makeSchema } from './makeSchema'
export { arg, booleanArg, floatArg, idArg, intArg, stringArg } from './definitions/args'

@@ -8,0 +8,0 @@ export { decorateType } from './definitions/decorateType'

@@ -603,1 +603,11 @@ import * as fs from 'fs'

}
/**
* A specially typed version of `Array.isArray` to work around [this
* issue](https://github.com/microsoft/TypeScript/issues/17002).
*/
export function isArray<T>(
arg: T | {}
): arg is T extends readonly any[] ? (unknown extends T ? never : readonly any[]) : any[] {
return Array.isArray(arg)
}

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

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