Comparing version 0.12.0-rc.3 to 0.12.0-rc.4
# Changelog | ||
### 0.12.0 final (unreleased) | ||
- refactor: Remove NEXUS_SHOULD_GENERATE_ARTIFACTS env var | ||
- feat: Add `shouldExitAfterGenerateArtifacts` | ||
- Warn on missing `outputs` in `makeSchema` config | ||
### 0.12.0-rc.2, rc.3 | ||
- fix: bug in nullability check plugin | ||
### 0.12.0-rc | ||
@@ -9,3 +19,3 @@ | ||
- feat: Adds "Plugins" API, [see the docs]() for more info on what all these can help accomplish | ||
- feat: Adds "Plugins" API, [see the docs](docs/api-plugins.md) for more info on what all these can help accomplish | ||
@@ -48,6 +58,6 @@ - feat(plugin): Add `nullabilityGuardPlugin`. See [the docs](docs/plugin-nullabilityGuard.md) for more info | ||
- feat(config): env var for should-generate-artifacts (#244) | ||
- feat(config): <strike>env var for should-generate-artifacts (#244) | ||
You can now set the `shouldGenerateArtifacts` config option by env var | ||
`NEXUS_SHOULD_GENERATE_ARTIFACTS=true|false`. | ||
`NEXUS_SHOULD_GENERATE_ARTIFACTS=true|false`.</strike> (removed, see 0.12 release notes) | ||
@@ -60,3 +70,3 @@ - fix(typegen): delete prev file before writing next (#252) | ||
* feat: by default typegen as an @types package (#230) | ||
* feat: <strike>by default typegen as an @types package (#230) | ||
@@ -72,3 +82,3 @@ BREAKING CHANGE | ||
`outputs` have not been configured (before, they were required). The | ||
heuristics of `shouldGenerateArtifacts` remain unchanged. | ||
heuristics of `shouldGenerateArtifacts` remain unchanged.</strike> (removed, see 0.12 release notes) | ||
@@ -75,0 +85,0 @@ ### 0.11.7 |
@@ -319,2 +319,3 @@ import { GraphQLEnumType, GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldConfigMap, GraphQLFieldResolver, GraphQLInputFieldConfig, GraphQLInputFieldConfigMap, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType, GraphQLField, GraphQLType } from "graphql"; | ||
export interface BuildTypes<TypeMapDefs extends Record<string, GraphQLNamedType>> { | ||
finalConfig: BuilderConfig; | ||
typeMap: TypeMapDefs; | ||
@@ -326,12 +327,2 @@ missingTypes: Record<string, MissingType>; | ||
/** | ||
* Builds the types, normalizing the "types" passed into the schema for a | ||
* better developer experience. This is primarily useful for testing | ||
* type generation | ||
*/ | ||
export declare function buildTypes<TypeMapDefs extends Record<string, GraphQLNamedType> = any>(types: any, config?: BuilderConfig): BuildTypes<TypeMapDefs>; | ||
/** | ||
* Internal build types woring with config rather than options. | ||
*/ | ||
export declare function buildTypesInternal<TypeMapDefs extends Record<string, GraphQLNamedType> = any>(types: any, config: BuilderConfig): BuildTypes<TypeMapDefs>; | ||
/** | ||
* Builds the schema, we may return more than just the schema | ||
@@ -343,2 +334,3 @@ * from this one day. | ||
missingTypes: Record<string, MissingType>; | ||
finalConfig: BuilderConfig; | ||
}; | ||
@@ -345,0 +337,0 @@ /** |
@@ -378,2 +378,3 @@ "use strict"; | ||
return { | ||
finalConfig: this.config, | ||
typeMap: this.finalTypeMap, | ||
@@ -957,21 +958,2 @@ schemaExtension: this.schemaExtension, | ||
/** | ||
* Builds the types, normalizing the "types" passed into the schema for a | ||
* better developer experience. This is primarily useful for testing | ||
* type generation | ||
*/ | ||
function buildTypes(types, config = { outputs: false }) { | ||
const internalConfig = utils_1.resolveTypegenConfig(config); | ||
return buildTypesInternal(types, internalConfig); | ||
} | ||
exports.buildTypes = buildTypes; | ||
/** | ||
* Internal build types woring with config rather than options. | ||
*/ | ||
function buildTypesInternal(types, config) { | ||
const builder = new SchemaBuilder(config); | ||
builder.addTypes(types); | ||
return builder.getFinalTypeMap(); | ||
} | ||
exports.buildTypesInternal = buildTypesInternal; | ||
/** | ||
* Builds the schema, we may return more than just the schema | ||
@@ -981,3 +963,5 @@ * from this one day. | ||
function makeSchemaInternal(config) { | ||
const { typeMap, missingTypes, schemaExtension, onAfterBuildFns, } = buildTypesInternal(config.types, config); | ||
const builder = new SchemaBuilder(config); | ||
builder.addTypes(config.types); | ||
const { finalConfig, typeMap, missingTypes, schemaExtension, onAfterBuildFns, } = builder.getFinalTypeMap(); | ||
const { Query, Mutation, Subscription } = typeMap; | ||
@@ -1006,3 +990,3 @@ /* istanbul ignore next */ | ||
onAfterBuildFns.forEach((fn) => fn(schema)); | ||
return { schema, missingTypes }; | ||
return { schema, missingTypes, finalConfig }; | ||
} | ||
@@ -1018,4 +1002,4 @@ exports.makeSchemaInternal = makeSchemaInternal; | ||
function makeSchema(config) { | ||
const typegenConfig = utils_1.resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = utils_1.resolveTypegenConfig(finalConfig); | ||
if (typegenConfig.outputs.schema || typegenConfig.outputs.typegen) { | ||
@@ -1033,2 +1017,3 @@ // Generating in the next tick allows us to use the schema | ||
"(not enabled)"}`); | ||
process.exit(0); | ||
}) | ||
@@ -1056,4 +1041,4 @@ .catch((e) => { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const typegenConfig = utils_1.resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = utils_1.resolveTypegenConfig(finalConfig); | ||
utils_1.assertNoMissingTypes(schema, missingTypes); | ||
@@ -1070,4 +1055,4 @@ yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifacts(schema); | ||
generateSchema.withArtifacts = (config, typeFilePath) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const typegenConfig = utils_1.resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = utils_1.resolveTypegenConfig(finalConfig); | ||
utils_1.assertNoMissingTypes(schema, missingTypes); | ||
@@ -1074,0 +1059,0 @@ const { schemaTypes, tsTypes } = yield new typegenMetadata_1.TypegenMetadata(typegenConfig).generateArtifactContents(schema, typeFilePath); |
@@ -10,13 +10,8 @@ import { NexusOutputFieldConfig } from "./definitions/definitionBlocks"; | ||
extensions?: { | ||
nexus?: NexusTypeExtension<any>; | ||
nexus?: { | ||
config: any; | ||
}; | ||
}; | ||
}; | ||
export declare type NexusTypeExtensions = NexusObjectTypeExtension | NexusInterfaceTypeExtension; | ||
declare type PossibleTypes = "ObjectType" | "UnionType" | "ScalarType" | "IntefaceType" | "InputObjectType" | "Schema"; | ||
declare type ExtensionConfigFor<T extends PossibleTypes> = any; | ||
export declare class NexusTypeExtension<T extends PossibleTypes> { | ||
readonly type: T; | ||
readonly config: ExtensionConfigFor<T>; | ||
constructor(type: T, config: ExtensionConfigFor<T>); | ||
} | ||
/** | ||
@@ -67,2 +62,1 @@ * Container object living on `fieldDefinition.extensions.nexus` | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
class NexusTypeExtension { | ||
constructor(type, config) { | ||
this.type = type; | ||
this.config = config; | ||
} | ||
} | ||
exports.NexusTypeExtension = NexusTypeExtension; | ||
/** | ||
@@ -12,0 +5,0 @@ * Container object living on `fieldDefinition.extensions.nexus` |
export { createPlugin, PluginConfig, PluginBuilderLens } from "./plugin"; | ||
export { buildTypes, makeSchema } from "./builder"; | ||
export { makeSchema } from "./builder"; | ||
export { arg, booleanArg, floatArg, idArg, intArg, stringArg, } from "./definitions/args"; | ||
@@ -4,0 +4,0 @@ export { enumType } from "./definitions/enumType"; |
@@ -8,3 +8,2 @@ "use strict"; | ||
var builder_1 = require("./builder"); | ||
exports.buildTypes = builder_1.buildTypes; | ||
exports.makeSchema = builder_1.makeSchema; | ||
@@ -11,0 +10,0 @@ var args_1 = require("./definitions/args"); |
@@ -9,2 +9,3 @@ "use strict"; | ||
let prettier; | ||
/* istanbul ignore next */ | ||
try { | ||
@@ -20,2 +21,3 @@ prettier = require("prettier"); | ||
if (typeof prettierConfig === "string") { | ||
/* istanbul ignore if */ | ||
if (!path_1.default.isAbsolute(prettierConfig)) { | ||
@@ -22,0 +24,0 @@ console.error(new Error(`Expected prettierrc path to be absolute, saw ${prettierConfig}. Skipping formatting.`)); |
import { GraphQLSchema } from "graphql"; | ||
import { TypegenInfo, BuilderConfig } from "./builder"; | ||
import { NexusGraphQLSchema } from "./definitions/_types"; | ||
export interface TypegenMetadataConfig extends Omit<BuilderConfig, "outputs"> { | ||
export interface TypegenMetadataConfig extends Omit<BuilderConfig, "outputs" | "shouldGenerateArtifacts"> { | ||
outputs: { | ||
@@ -6,0 +6,0 @@ schema: false | string; |
@@ -97,3 +97,4 @@ "use strict"; | ||
catch (e) { | ||
if (e.code !== "ENOENT") { | ||
/* istanbul ignore next */ | ||
if (e.code !== "ENOENT" && e.code !== "ENOTDIR") { | ||
throw e; | ||
@@ -100,0 +101,0 @@ } |
@@ -634,2 +634,3 @@ "use strict"; | ||
strLike.imports.forEach((i) => { | ||
/* istanbul ignore if */ | ||
if (!wrapping_1.isNexusPrintedGenTypingImport(i)) { | ||
@@ -636,0 +637,0 @@ console.warn(`Expected printedGenTypingImport, saw ${i}`); |
@@ -226,50 +226,20 @@ "use strict"; | ||
function resolveTypegenConfig(config) { | ||
const { outputs } = config, rest = tslib_1.__rest(config, ["outputs"]); | ||
const { outputs, shouldGenerateArtifacts = Boolean(!process.env.NODE_ENV || process.env.NODE_ENV === "development") } = config, rest = tslib_1.__rest(config, ["outputs", "shouldGenerateArtifacts"]); | ||
let typegenPath = false; | ||
let schemaPath = false; | ||
if (outputs && typeof outputs === "object") { | ||
if (typeof outputs.schema === "string") { | ||
exports.assertAbsolutePath(outputs.schema, "outputs.schema"); | ||
schemaPath = exports.assertAbsolutePath(outputs.schema, "outputs.schema"); | ||
} | ||
if (typeof outputs.typegen === "string") { | ||
exports.assertAbsolutePath(outputs.typegen, "outputs.typegen"); | ||
typegenPath = exports.assertAbsolutePath(outputs.typegen, "outputs.typegen"); | ||
} | ||
} | ||
const shouldGenerateArtifacts = typeof config.shouldGenerateArtifacts === "boolean" | ||
? config.shouldGenerateArtifacts | ||
: process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS === "true" | ||
? true | ||
: process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS === "false" | ||
? false | ||
: Boolean(!process.env.NODE_ENV || process.env.NODE_ENV === "development"); | ||
const defaultSchemaPath = path_1.default.join(process.cwd(), "schema.graphql"); | ||
const defaultTypegenPath = path_1.default.join(__dirname, "../../@types/nexus-typegen/index.d.ts"); | ||
let finalSchemaPath = false; | ||
let finalTypegenPath = false; | ||
if (shouldGenerateArtifacts === false || outputs === false) { | ||
finalTypegenPath = false; | ||
finalSchemaPath = false; | ||
else if (outputs !== false) { | ||
console.warn(`You should specify a configuration value for outputs in Nexus' makeSchema. ` + | ||
`Provide one to remove this warning.`); | ||
} | ||
else if (outputs === undefined || outputs === true) { | ||
finalTypegenPath = defaultTypegenPath; | ||
finalSchemaPath = outputs === true ? defaultSchemaPath : false; | ||
} | ||
else if (typeof outputs === "object") { | ||
if (outputs.typegen === undefined || outputs.typegen === true) { | ||
finalTypegenPath = defaultTypegenPath; | ||
} | ||
else if (typeof outputs.typegen === "string") { | ||
finalTypegenPath = outputs.typegen; | ||
} | ||
if (outputs.schema === undefined) { | ||
finalSchemaPath = false; | ||
} | ||
else if (outputs.schema === true) { | ||
finalSchemaPath = defaultSchemaPath; | ||
} | ||
else if (typeof outputs.schema === "string") { | ||
finalSchemaPath = outputs.schema; | ||
} | ||
} | ||
return Object.assign(Object.assign({}, rest), { shouldGenerateArtifacts, outputs: { | ||
typegen: finalTypegenPath, | ||
schema: finalSchemaPath, | ||
return Object.assign(Object.assign({}, rest), { outputs: { | ||
typegen: shouldGenerateArtifacts ? typegenPath : false, | ||
schema: shouldGenerateArtifacts ? schemaPath : false, | ||
} }); | ||
@@ -351,9 +321,2 @@ } | ||
}); | ||
rights.forEach((r) => { | ||
if (lefts.has(r)) { | ||
boths.add(r); | ||
lefts.delete(r); | ||
rights.delete(r); | ||
} | ||
}); | ||
return [lefts, boths, rights]; | ||
@@ -360,0 +323,0 @@ } |
{ | ||
"name": "nexus", | ||
"version": "0.12.0-rc.3", | ||
"version": "0.12.0-rc.4", | ||
"description": "Scalable, strongly typed GraphQL schema development", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,3 +6,3 @@ <p align="center"> | ||
[![CircleCI](https://img.shields.io/circleci/build/github/prisma-labs/nexus)](https://circleci.com/gh/prisma/nexus) | ||
[![CircleCI](https://img.shields.io/circleci/build/github/prisma-labs/nexus)](https://circleci.com/gh/prisma-labs/nexus) | ||
[![npm version](https://badge.fury.io/js/nexus.svg)](https://badge.fury.io/js/nexus) | ||
@@ -62,3 +62,3 @@ [![Slack](https://slack.prisma.io/badge.svg)](https://slack.prisma.io/) | ||
If you're interested in examples using the [`nexus-prisma`](https://github.com/prisma/nexus-prisma) plugin, check out the official [`prisma-examples`](https://github.com/prisma/prisma-examples/) repo: | ||
If you're interested in examples using the [`nexus-prisma`](https://github.com/prisma-labs/nexus-prisma) plugin, check out the official [`prisma-examples`](https://github.com/prisma/prisma-examples/) repo: | ||
@@ -78,6 +78,6 @@ - [GraphQL blogging app](https://github.com/prisma/prisma-examples/tree/master/typescript/graphql) | ||
- Auto-generated graphql SDL schema, great for when seeing how any code changes affected the schema | ||
- Lots of good [examples](https://github.com/prisma/nexus/tree/develop/examples) to get you started and thorough [API documentation](https://nexus.js.org/docs/api-core-concepts) | ||
- Lots of good [examples](https://github.com/prisma-labs/nexus/tree/develop/examples) to get you started and thorough [API documentation](https://nexus.js.org/docs/api-core-concepts) | ||
- Full type-safety for free | ||
- Internal structure allows library authors to build more advanced abstractions | ||
- Independent from Prisma, but integrates nicely using the [`nexus-prisma`](https://github.com/prisma/nexus-prisma) plugin | ||
- Independent from Prisma, but integrates nicely using the [`nexus-prisma`](https://github.com/prisma-labs/nexus-prisma) plugin | ||
- Allows code re-use by creating higher level "functions" which wrap common fields | ||
@@ -84,0 +84,0 @@ |
@@ -784,2 +784,3 @@ import { | ||
return { | ||
finalConfig: this.config, | ||
typeMap: this.finalTypeMap, | ||
@@ -1545,2 +1546,3 @@ schemaExtension: this.schemaExtension!, | ||
> { | ||
finalConfig: BuilderConfig; | ||
typeMap: TypeMapDefs; | ||
@@ -1553,28 +1555,2 @@ missingTypes: Record<string, MissingType>; | ||
/** | ||
* Builds the types, normalizing the "types" passed into the schema for a | ||
* better developer experience. This is primarily useful for testing | ||
* type generation | ||
*/ | ||
export function buildTypes< | ||
TypeMapDefs extends Record<string, GraphQLNamedType> = any | ||
>( | ||
types: any, | ||
config: BuilderConfig = { outputs: false } | ||
): BuildTypes<TypeMapDefs> { | ||
const internalConfig = resolveTypegenConfig(config); | ||
return buildTypesInternal<TypeMapDefs>(types, internalConfig); | ||
} | ||
/** | ||
* Internal build types woring with config rather than options. | ||
*/ | ||
export function buildTypesInternal< | ||
TypeMapDefs extends Record<string, GraphQLNamedType> = any | ||
>(types: any, config: BuilderConfig): BuildTypes<TypeMapDefs> { | ||
const builder = new SchemaBuilder(config); | ||
builder.addTypes(types); | ||
return builder.getFinalTypeMap(); | ||
} | ||
/** | ||
* Builds the schema, we may return more than just the schema | ||
@@ -1584,3 +1560,6 @@ * from this one day. | ||
export function makeSchemaInternal(config: SchemaConfig) { | ||
const builder = new SchemaBuilder(config); | ||
builder.addTypes(config.types); | ||
const { | ||
finalConfig, | ||
typeMap, | ||
@@ -1590,3 +1569,3 @@ missingTypes, | ||
onAfterBuildFns, | ||
} = buildTypesInternal(config.types, config); | ||
} = builder.getFinalTypeMap(); | ||
const { Query, Mutation, Subscription } = typeMap; | ||
@@ -1625,3 +1604,3 @@ | ||
return { schema, missingTypes }; | ||
return { schema, missingTypes, finalConfig }; | ||
} | ||
@@ -1637,4 +1616,4 @@ | ||
export function makeSchema(config: SchemaConfig): NexusGraphQLSchema { | ||
const typegenConfig = resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = resolveTypegenConfig(finalConfig); | ||
@@ -1655,2 +1634,3 @@ if (typegenConfig.outputs.schema || typegenConfig.outputs.typegen) { | ||
"(not enabled)"}`); | ||
process.exit(0); | ||
}) | ||
@@ -1678,4 +1658,4 @@ .catch((e) => { | ||
): Promise<NexusGraphQLSchema> { | ||
const typegenConfig = resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = resolveTypegenConfig(finalConfig); | ||
assertNoMissingTypes(schema, missingTypes); | ||
@@ -1698,4 +1678,4 @@ await new TypegenMetadata(typegenConfig).generateArtifacts(schema); | ||
}> => { | ||
const typegenConfig = resolveTypegenConfig(config); | ||
const { schema, missingTypes } = makeSchemaInternal(config); | ||
const { schema, missingTypes, finalConfig } = makeSchemaInternal(config); | ||
const typegenConfig = resolveTypegenConfig(finalConfig); | ||
assertNoMissingTypes(schema, missingTypes); | ||
@@ -1702,0 +1682,0 @@ const { schemaTypes, tsTypes } = await new TypegenMetadata( |
@@ -11,3 +11,5 @@ import { NexusOutputFieldConfig } from "./definitions/definitionBlocks"; | ||
extensions?: { | ||
nexus?: NexusTypeExtension<any>; | ||
nexus?: { | ||
config: any; | ||
}; | ||
}; | ||
@@ -20,16 +22,2 @@ }; | ||
type PossibleTypes = | ||
| "ObjectType" | ||
| "UnionType" | ||
| "ScalarType" | ||
| "IntefaceType" | ||
| "InputObjectType" | ||
| "Schema"; | ||
type ExtensionConfigFor<T extends PossibleTypes> = any; | ||
export class NexusTypeExtension<T extends PossibleTypes> { | ||
constructor(readonly type: T, readonly config: ExtensionConfigFor<T>) {} | ||
} | ||
/** | ||
@@ -36,0 +24,0 @@ * Container object living on `fieldDefinition.extensions.nexus` |
// All of the Public API definitions | ||
export { createPlugin, PluginConfig, PluginBuilderLens } from "./plugin"; | ||
export { buildTypes, makeSchema } from "./builder"; | ||
export { makeSchema } from "./builder"; | ||
export { | ||
@@ -5,0 +5,0 @@ arg, |
@@ -16,2 +16,3 @@ import path from "path"; | ||
let prettier: typeof import("prettier"); | ||
/* istanbul ignore next */ | ||
try { | ||
@@ -28,2 +29,3 @@ prettier = require("prettier") as typeof import("prettier"); | ||
if (typeof prettierConfig === "string") { | ||
/* istanbul ignore if */ | ||
if (!path.isAbsolute(prettierConfig)) { | ||
@@ -30,0 +32,0 @@ console.error( |
@@ -13,3 +13,4 @@ import { GraphQLSchema, lexicographicSortSchema, printSchema } from "graphql"; | ||
export interface TypegenMetadataConfig extends Omit<BuilderConfig, "outputs"> { | ||
export interface TypegenMetadataConfig | ||
extends Omit<BuilderConfig, "outputs" | "shouldGenerateArtifacts"> { | ||
outputs: { | ||
@@ -113,3 +114,4 @@ schema: false | string; | ||
} catch (e) { | ||
if (e.code !== "ENOENT") { | ||
/* istanbul ignore next */ | ||
if (e.code !== "ENOENT" && e.code !== "ENOTDIR") { | ||
throw e; | ||
@@ -116,0 +118,0 @@ } |
@@ -780,2 +780,3 @@ import { | ||
strLike.imports.forEach((i) => { | ||
/* istanbul ignore if */ | ||
if (!isNexusPrintedGenTypingImport(i)) { | ||
@@ -782,0 +783,0 @@ console.warn(`Expected printedGenTypingImport, saw ${i}`); |
@@ -314,59 +314,31 @@ import { | ||
): TypegenMetadataConfig { | ||
const { outputs, ...rest } = config; | ||
const { | ||
outputs, | ||
shouldGenerateArtifacts = Boolean( | ||
!process.env.NODE_ENV || process.env.NODE_ENV === "development" | ||
), | ||
...rest | ||
} = config; | ||
let typegenPath: string | false = false; | ||
let schemaPath: string | false = false; | ||
if (outputs && typeof outputs === "object") { | ||
if (typeof outputs.schema === "string") { | ||
assertAbsolutePath(outputs.schema, "outputs.schema"); | ||
schemaPath = assertAbsolutePath(outputs.schema, "outputs.schema"); | ||
} | ||
if (typeof outputs.typegen === "string") { | ||
assertAbsolutePath(outputs.typegen, "outputs.typegen"); | ||
typegenPath = assertAbsolutePath(outputs.typegen, "outputs.typegen"); | ||
} | ||
} else if (outputs !== false) { | ||
console.warn( | ||
`You should specify a configuration value for outputs in Nexus' makeSchema. ` + | ||
`Provide one to remove this warning.` | ||
); | ||
} | ||
const shouldGenerateArtifacts = | ||
typeof config.shouldGenerateArtifacts === "boolean" | ||
? config.shouldGenerateArtifacts | ||
: process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS === "true" | ||
? true | ||
: process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS === "false" | ||
? false | ||
: Boolean( | ||
!process.env.NODE_ENV || process.env.NODE_ENV === "development" | ||
); | ||
const defaultSchemaPath = path.join(process.cwd(), "schema.graphql"); | ||
const defaultTypegenPath = path.join( | ||
__dirname, | ||
"../../@types/nexus-typegen/index.d.ts" | ||
); | ||
let finalSchemaPath: false | string = false; | ||
let finalTypegenPath: false | string = false; | ||
if (shouldGenerateArtifacts === false || outputs === false) { | ||
finalTypegenPath = false; | ||
finalSchemaPath = false; | ||
} else if (outputs === undefined || outputs === true) { | ||
finalTypegenPath = defaultTypegenPath; | ||
finalSchemaPath = outputs === true ? defaultSchemaPath : false; | ||
} else if (typeof outputs === "object") { | ||
if (outputs.typegen === undefined || outputs.typegen === true) { | ||
finalTypegenPath = defaultTypegenPath; | ||
} else if (typeof outputs.typegen === "string") { | ||
finalTypegenPath = outputs.typegen; | ||
} | ||
if (outputs.schema === undefined) { | ||
finalSchemaPath = false; | ||
} else if (outputs.schema === true) { | ||
finalSchemaPath = defaultSchemaPath; | ||
} else if (typeof outputs.schema === "string") { | ||
finalSchemaPath = outputs.schema; | ||
} | ||
} | ||
return { | ||
...rest, | ||
shouldGenerateArtifacts, | ||
outputs: { | ||
typegen: finalTypegenPath, | ||
schema: finalSchemaPath, | ||
typegen: shouldGenerateArtifacts ? typegenPath : false, | ||
schema: shouldGenerateArtifacts ? schemaPath : false, | ||
}, | ||
@@ -466,9 +438,2 @@ }; | ||
}); | ||
rights.forEach((r) => { | ||
if (lefts.has(r)) { | ||
boths.add(r); | ||
lefts.delete(r); | ||
rights.delete(r); | ||
} | ||
}); | ||
@@ -475,0 +440,0 @@ return [lefts, boths, rights]; |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
8
806961
12475