From 1c1cd13f22d087e138a25bc44267f24fab24f941 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Thu, 18 Mar 2021 20:52:31 -0400 Subject: [PATCH] feat: support projecting enums (#18) --- README.md | 140 +- package.json | 2 + src/generator/helpers/JSDocTemplates.ts | 259 +-- src/generator/models/declaration.ts | 104 +- src/generator/models/javascript.ts | 91 +- tests/__helpers__.ts | 58 +- .../__snapshots__/e2e.test.ts.snap} | 45 +- .../scalars.test.ts => e2e/e2e.test.ts} | 62 +- .../__snapshots__/enum.test.ts.snap | 28 + tests/integration/enum.test.ts | 51 + tests/unit/__snapshots__/jsdoc.test.ts.snap | 442 ------ tests/unit/__snapshots__/scalars.test.ts.snap | 1158 -------------- .../__snapshots__/enum.test.ts.snap | 195 +++ .../__snapshots__/enumDoc.test.ts.snap | 195 +++ .../modelDocumentation.test.ts.snap | 631 ++++++++ .../modelScalarFields.test.ts.snap | 1400 +++++++++++++++++ .../typescriptDeclarationFile/enum.test.ts | 22 + .../typescriptDeclarationFile/enumDoc.test.ts | 22 + .../modelDocumentation.test.ts} | 10 +- .../modelScalarFields.test.ts} | 16 +- yarn.lock | 205 ++- 21 files changed, 3298 insertions(+), 1838 deletions(-) rename tests/{integration/__snapshots__/scalars.test.ts.snap => e2e/__snapshots__/e2e.test.ts.snap} (95%) rename tests/{integration/scalars.test.ts => e2e/e2e.test.ts} (80%) create mode 100644 tests/integration/__snapshots__/enum.test.ts.snap create mode 100644 tests/integration/enum.test.ts delete mode 100644 tests/unit/__snapshots__/jsdoc.test.ts.snap delete mode 100644 tests/unit/__snapshots__/scalars.test.ts.snap create mode 100644 tests/unit/typescriptDeclarationFile/__snapshots__/enum.test.ts.snap create mode 100644 tests/unit/typescriptDeclarationFile/__snapshots__/enumDoc.test.ts.snap create mode 100644 tests/unit/typescriptDeclarationFile/__snapshots__/modelDocumentation.test.ts.snap create mode 100644 tests/unit/typescriptDeclarationFile/__snapshots__/modelScalarFields.test.ts.snap create mode 100644 tests/unit/typescriptDeclarationFile/enum.test.ts create mode 100644 tests/unit/typescriptDeclarationFile/enumDoc.test.ts rename tests/unit/{jsdoc.test.ts => typescriptDeclarationFile/modelDocumentation.test.ts} (80%) rename tests/unit/{scalars.test.ts => typescriptDeclarationFile/modelScalarFields.test.ts} (77%) diff --git a/README.md b/README.md index 91cfbdc3f..727174c61 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,47 @@ +**⚠️ Currently in development - _not to be used in Production_.** Follow progress from [here](https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1039). + # nexus-prisma [![trunk](https://github.com/prisma/nexus-prisma/actions/workflows/trunk.yml/badge.svg)](https://github.com/prisma/nexus-prisma/actions/workflows/trunk.yml) -Official Prisma plugin for Nexus. -**Currently in development - not to be used in Production.** Follow the progress from [here](https://github.com/graphql-nexus/nexus-plugin-prisma/issues/1039). +Official Prisma plugin for Nexus. -## Installation + -``` -npm add nexus-prisma graphql @prisma/client -npm add --dev prisma -``` +- [Usage](#usage) +- [Roadmap](#roadmap) +- [Features](#features) + - [Type-safe seamless generated library code](#type-safe-seamless-generated-library-code) + - [Scalar Mapping & Custom GraphQL Scalars for Native Prisma Scalars](#scalar-mapping--custom-graphql-scalars-for-native-prisma-scalars) + - [Prisma ID field to GraphQL ID scalar type mapping](#prisma-id-field-to-graphql-id-scalar-type-mapping) + - [Prisma Schema model & field documentation re-use](#prisma-schema-model--field-documentation-re-use) + - [GraphQL documentation for your API clients](#graphql-documentation-for-your-api-clients) + - [Internal JSDoc for your team](#internal-jsdoc-for-your-team) + - [Refined DX](#refined-dx) +- [Notes](#notes) -> `graphql` and `@prisma/client` are peer dependencies. `prisma` is for the Prisma CLI which you'll probably want during development. + ## Usage +1. Install dependencies + + ``` + npm add nexus-prisma graphql @prisma/client + npm add --dev prisma + ``` + + > `graphql` and `@prisma/client` are peer dependencies. `prisma` is for the Prisma CLI which you'll probably want during development. + 1. Add a `nexus-prisma` generator block to your Prisma Schema. + + > If you are using `prisma@=<2.17.x` then you must use the Nexus Prisma Prisma generator name of `nexus_prisma` instead of `nexus-prisma`. See [notes](#notes) for more detail. + 1. Run `prisma generate` in your terminal. -1. Import models from `nexus-prisma` and then pass them to your Nexus type definition and field definition configurations. In this way you will be effectively projecting models from your data layer into GraphQL types in your API layer. -### Example +1. Import models from `nexus-prisma` and then pass them to your Nexus type definition and field definition configurations. In this way you will be effectively projecting models from your data layer into GraphQL types in your API layer. -> **Note:** If you are using Prisma@=<2.17.x then you _must_ use the Nexus Prisma Prisma generator name of `nexus_prisma` instead of `nexus-prisma`. This is because prior to prisma@2.18.x there was a hardcode check for `nexus-prisma` generator name wherein it would give feedback about it no longer being a generator. +##### Example ```prisma @@ -43,7 +62,7 @@ model User { ``` ``` -$ prisma generate +prisma generate ``` ```ts @@ -65,32 +84,32 @@ export const schema = makeSchema({ ## Roadmap -#### Done +##### Done - [x] ([#4](https://github.com/prisma/nexus-prisma/issues/4)) Support for Prisma Model field types that map to standard GraphQL scalars - [x] ([#8](https://github.com/prisma/nexus-prisma/issues/8)) Support for Prisma Model field types of `DateTime` & `Json` +- [x] ([#16](https://github.com/prisma/nexus-prisma/issues/16)) Support for Prisma enums -#### Shortterm +##### Shortterm -- [ ] ([#16](https://github.com/prisma/nexus-prisma/issues/16)) Support for Prisma enums - [ ] Support for Prisma Model field types of remaiming scalars (`Byes`, etc.) -#### Midterm +##### Midterm - [ ] Support for Prisma Model field types relating to other Models 1:1 - [ ] Support for Prisma Model field types relating to other Models 1:n - [ ] Support for Prisma Model field types relating to other Models n:n -#### Longterm +##### Longterm - [ ] Nexus Plugin? `t.model`? `t.crud`? - [ ] ... ## Features -> **Note**: ⛑ The following use abbreviated examples that skip a complete setup of passing Nexus type definition to Nexus `makeSchema`. If you are new to Nexus, Consider reading the [official Nexus tutorial](https://nxs.li/tutorial) before jumping into Nexus Prisma. +> **Note**: ⛑ The following use abbreviated examples that skip a complete setup of passing Nexus type definition to Nexus' `makeSchema`. If you are new to Nexus, Consider reading the [official Nexus tutorial](https://nxs.li/tutorial) before jumping into Nexus Prisma. -### Type-safe seamless generated library code +### Type-safe Generated Library Code Following the same philosophy as Prisma Client, Nexus Prisma uses generation to create an API that feels tailor made for your project. @@ -116,9 +135,30 @@ objectType({ }) ``` -### Scalar Mapping & Custom GraphQL Scalars for Native Prisma Scalars +### Project Enums + +Every enum defined in your Prisma schema becomes importable as a Nexus enum type definition configuration. This makes it trivial to project enums from your database layer into your API layer. + +```prisma +enum SomeEnum { + foo + bar +} +``` -Like GraphQL [Prisma has the concept of scalar types](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference/#model-field-scalar-types). Some of the Prisma scalars can be naturally mapped to standard GraphQL scalars. The mapping is as follows: +```ts +import { SomeEnum } from 'nexus-prisma' +import { enumType } from 'nexus' + +SomeEnum.name // 'SomeEnum' +SomeEnum.members // ['foo', 'bar'] + +enumType(SomeEnum) +``` + +### Project Scalars + +Like GraphQL, [Prisma has the concept of scalar types](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference/#model-field-scalar-types). Some of the Prisma scalars can be naturally mapped to standard GraphQL scalars. The mapping is as follows: **Prisma Standard Scalar to GraphQL Standard Scalar Mapping** @@ -154,25 +194,7 @@ makeSchema({ }) ``` -The following is a brief example how you could roll the implementations yourself: - -```ts -import { GraphQLScalarType } from 'graphql' -import { JSONObjectResolver, DateTimeResolver } from 'graphql-scalars' -import { asNexusMethod, makeSchema } from 'nexus' - -const jsonScalar = new GraphQLScalarType({ - ...JSONObjectResolver, - // Override the default 'JsonObject' name with one that matches what Nexus Prisma expects. - name: 'Json', -}) - -const dateTimeScalar = new GraphQLScalarType(DateTimeResolver) - -makeSchema({ - types: [asNexusMethod(jsonScalar, 'json'), asNexusMethod(dateTimeScalar, 'dateTime')], -}) -``` +There is a [recipe below](#Supply-custom-custom-scalars-to-your-GraphQL-schema) showing how to add your own custom scalars if you want. ### Prisma ID field to GraphQL ID scalar type mapping @@ -203,9 +225,7 @@ type User { } ``` -### Prisma Schema model & field documentation re-use - -#### GraphQL documentation for your API clients +### Prisma Schema docs re-used for GraphQL schema doc ```prisma /// A user. @@ -243,7 +263,7 @@ type User { } ``` -#### Internal JSDoc for your team +### Prisma Schema docs re-used for JSDoc ```prisma /// A user. @@ -264,15 +284,15 @@ User.id // JSDoc: A stable identifier to find users by. These are finer points that aren't perhaps worth a top-level point but none the less add up toward a thoughtful developer experience. -##### Default JSDoc Prompts +##### Default JSDoc Fields and models that you do not document will result in a helpful default JSDoc that teaches you about this. -##### Runtime Proxy +##### Defualt Runtime When your project is in a state where the generated Nexus Prisma part is missing (new repo clone, reinstalled deps, etc.) Nexus Prisma gives you a default runtime export named `PleaseRunPrismaGenerate` and will error with a clear message. -##### Opt-outable friendly runtime peer dependency checks +##### Peer-Dependency Validation When `nexus-prisma` is imported it will validate that your project has peer dependencies setup correctly. @@ -287,6 +307,32 @@ PEER_DEPENDENCY_CHECK=false|0 - `nexus-prisma/scalars` offers a default export you can easily auto-import by name: `NexusPrismaScalars`. +## Recipes + +### Supply custom custom scalars to your GraphQL schema + +The following is a brief example how you could add your own custom GraphQL custom scalars to satisfy Nexus Prisma. Note that most of the time using the defaults exported by `nexus-prisma/scalars` will probably be good enough for you. + +```ts +import { GraphQLScalarType } from 'graphql' +import { JSONObjectResolver, DateTimeResolver } from 'graphql-scalars' +import { asNexusMethod, makeSchema } from 'nexus' + +const jsonScalar = new GraphQLScalarType({ + ...JSONObjectResolver, + // Override the default 'JsonObject' name with one that matches what Nexus Prisma expects. + name: 'Json', +}) + +const dateTimeScalar = new GraphQLScalarType(DateTimeResolver) + +makeSchema({ + types: [asNexusMethod(jsonScalar, 'json'), asNexusMethod(dateTimeScalar, 'dateTime')], +}) +``` + ## Notes - Versions of `nexus-prisma` package prior to `0.20` were a completely different version of the API, and had also become deprecated at one point to migrate to `nexus-plugin-prisma` when Nexus Framework was being worked on. All of that is history. + +- If you are using `prisma@=<2.17.x` then you must use the Nexus Prisma Prisma generator name of `nexus_prisma` instead of `nexus-prisma`. This is because prior to `prisma@2.18.x` there was a hardcode check for `nexus-prisma` that would fail with an error message about a now-old migration. diff --git a/package.json b/package.json index 932bd2aad..6bf7a0d4d 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "nexus_prisma": "./dist/cli/nexus-prisma.js" }, "scripts": { + "reflect:toc": "markdown-toc README.md -i --maxdepth 4", "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint . --ext .ts,.tsx --fix", @@ -56,6 +57,7 @@ "jest": "26.6.3", "jest-watch-typeahead": "0.6.1", "lodash": "^4.17.21", + "markdown-toc": "^1.2.0", "nexus": "^1.0.0", "nodemon": "^2.0.7", "prettier": "2.2.1", diff --git a/src/generator/helpers/JSDocTemplates.ts b/src/generator/helpers/JSDocTemplates.ts index a47f6a46d..f19303a7a 100644 --- a/src/generator/helpers/JSDocTemplates.ts +++ b/src/generator/helpers/JSDocTemplates.ts @@ -1,117 +1,186 @@ import { DMMF } from '@prisma/client/runtime' import endent from 'endent' -import { repeat } from 'lodash' - -export function jsDocForModel(model: DMMF.Model): string { - return model.documentation - ? endent` - /** - * ${model.documentation} - */ - ` - : missingModelDocumentation(model) +import { upperFirst } from 'lodash' + +type JSDoc = string + +type FieldModelParams = { + field: DMMF.Field + model: DMMF.Model +} + +/** + * Enum + */ + +export function jsDocForEnum(enum_: DMMF.DatamodelEnum): JSDoc { + const enumDoc = enum_.documentation ? `* ${enum_.documentation}` : enumMissingDoc(enum_) + return endent` + /** + ${enumIntro(enum_)} + * + ${enumDoc} + * + ${enumExample(enum_)} + */ + ` +} + +function enumIntro(enum_: DMMF.DatamodelEnum): string { + return endent` + * Nexus \`enumType\` configuration based on the \`${enum_.name}\` enum in your Prisma schema. + ` +} + +function enumExample(enum_: DMMF.DatamodelEnum): string { + return endent` + * @example + * + * import { enumType } from 'nexus' + * import { ${enum_.name} } from 'nexus-prisma' + * + * enumType(${enum_.name}) + ` } -export function jsDocForField({ field, model }: { field: DMMF.Field; model: DMMF.Model }): string { - return field.documentation - ? endent` - /** - * ${field.documentation} - */ - ` - : missingFieldDocumentation({ field, model }) +function enumMissingDoc(enum_: DMMF.DatamodelEnum): string { + return endent` + ${missingDocsIntro('enum')} + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * enum ${enum_.name} { + ${enum_.values.map((value) => `* ${value.name}`).join('\n')} + * } + * \`\`\` + * + ${missingDocsOutro} + ` } -export function missingModelDocumentation({ name }: DMMF.Model): string { +/** + * Model + */ + +export function jsDocForModel(model: DMMF.Model): JSDoc { + const modelDoc = model.documentation ? `* ${model.documentation}` : modelMissingDoc(model) return endent` /** - * ### 📔 Missing Model Documentation for \`${name}\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * ${jsDocDiviion('Example 1')} - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model ${name} { - * id String @id - * } - * \`\`\` - * - * ${jsDocDiviion('Example 2')} - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ + ${modelIntro(model)} + * + ${modelDoc} + * + ${modelExample(model)} + */ ` } -export function missingFieldDocumentation({ - field, - model, -}: { - field: DMMF.Field - model: DMMF.Model -}): string { +function modelIntro(model: DMMF.Model): string { + return endent` + * Nexus \`objectType\` related configuration based on the \`${model.name}\` model in your Prisma schema. + ` +} + +function modelMissingDoc(model: DMMF.Model): string { + // TODO once https://stackoverflow.com/questions/61893953/how-to-escape-symbol-in-jsdoc-for-vscode + // is resolved then we can write better examples below like: id String @id + return endent` + ${missingDocsIntro('model')} + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model ${model.name} { + * foo String + * } + * \`\`\` + * + ${missingDocsOutro} + ` +} + +function modelExample(model: DMMF.Model): string { + return endent` + * @example + * + * import { objectType } from 'nexus' + * import { ${model.name} } from 'nexus-prisma' + * + * objectType({ + * name: ${model.name}.$name + * description: ${model.name}.$description + * definition(t) { + * t.field(${model.name}.id.name, ${model.name}.id) + * } + * }) + ` +} + +/** + * Field + */ + +export function jsDocForField({ field, model }: FieldModelParams): JSDoc { + const fieldDocs = field.documentation ? `* ${field.documentation}` : fieldMissingDoc({ field, model }) return endent` /** - * ### 📔 Missing Field Documentation for \`${field.name}\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * ${jsDocDiviion('Example 1')} - * - * \`\`\`prisma - * model ${model.name} { - * /// Lorem ipsum dolor sit amet. - * ${field.name} ${field.type}${field.isRequired ? '' : '?'} - * } - * \`\`\` - * - * ${jsDocDiviion('Example 2')} - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ + ${fieldIntro({ field, model })} + * + ${fieldDocs} + * + ${fieldExample({ field, model })} + */ + ` +} + +function fieldIntro({ model, field }: FieldModelParams): string { + return endent` + * Nexus \`t.field\` related configuration based on the \`${model.name}.${field.name}\` field in your Prisma schema. + ` +} + +function fieldMissingDoc({ model, field }: FieldModelParams): string { + return endent` + ${missingDocsIntro('model')} + * \`\`\`prisma + * model ${model.name} { + * /// Lorem ipsum dolor sit amet. + * ${field.name} ${field.type}${field.isRequired ? '' : '?'} + * } + * \`\`\` + * + ${missingDocsOutro} + ` +} + +function fieldExample({ model, field }: FieldModelParams): string { + return endent` + * @example + * + * import { objectType } from 'nexus' + * import { ${model.name} } from 'nexus-prisma' + * + * objectType({ + * name: ${model.name}.$name + * description: ${model.name}.$description + * definition(t) { + * t.field(${model.name}.${field.name}.name, ${model.name}.${field.name}) + * } + * }) ` } /** - * Render a centered title with bars on either side filling left over space. - * - * Sized according to standard JSDoc window size in VSCode. + * Helpers */ -function jsDocDiviion(title: string): string { - const titlePadding = ' ' - const barLength = Math.floor(MAX_JS_DOC_LENGTH / 2 - title.length - titlePadding.length * 2) - const bar = repeat('–', barLength) + +function missingDocsIntro(kind: 'model' | 'enum' | 'field'): string { return endent` - #### ${bar}${titlePadding}${title}${titlePadding}${bar} + * ### ️⚠️ Missing Documentation for this ${upperFirst(kind)} + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * ` } -const MAX_JS_DOC_LENGTH = 72 +const missingDocsOutro = `* Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments).` diff --git a/src/generator/models/declaration.ts b/src/generator/models/declaration.ts index 20591bda8..48c97ea55 100644 --- a/src/generator/models/declaration.ts +++ b/src/generator/models/declaration.ts @@ -4,7 +4,7 @@ import { LiteralUnion } from 'type-fest' import { StandardGraphQLScalarType, StandardgraphQLScalarTypes } from '../../helpers/graphql' import { PrismaScalarType } from '../../helpers/prisma' import { allCasesHandled } from '../../helpers/utils' -import { jsDocForField, jsDocForModel } from '../helpers/JSDocTemplates' +import { jsDocForEnum, jsDocForField, jsDocForModel } from '../helpers/JSDocTemplates' import { ModuleSpec } from '../types' export function createModuleSpec(dmmf: DMMF.Document): ModuleSpec { @@ -16,34 +16,114 @@ export function createModuleSpec(dmmf: DMMF.Document): ModuleSpec { } } +const NO_ENUMS_DEFINED_COMMENT = endent` + // N/A –– You have not defined any models in your Prisma schema file. +` + +const NO_MODELS_DEFINED_COMMENT = endent` + // N/A –– You have not defined any enums in your Prisma schema file. +` + export function renderTypeScriptDeclarationForDocumentModels(dmmf: DMMF.Document): string { const models = dmmf.datamodel.models + const enums = dmmf.datamodel.enums return endent` import * as Nexus from 'nexus' import * as NexusCore from 'nexus/dist/core' // - // Types + // + // TYPES + // TYPES + // TYPES + // TYPES + // // declare namespace $Types { - ${models.map(renderTypeScriptDeclarationForModel).join('\n\n')} + // Models + + ${ + models.length === 0 + ? NO_MODELS_DEFINED_COMMENT + : models.map(renderTypeScriptDeclarationForModel).join('\n\n') + } + + // Enums + + ${ + enums.length === 0 + ? NO_ENUMS_DEFINED_COMMENT + : enums.map(renderTypeScriptDeclarationForEnum).join('\n\n') + } } // - // Exports + // + // EXPORTS + // EXPORTS + // EXPORTS + // EXPORTS + // + // + + // + // + // EXPORTS: PRISMA MODELS + // EXPORTS: PRISMA MODELS + // EXPORTS: PRISMA MODELS + // EXPORTS: PRISMA MODELS + // + // + + ${ + models.length === 0 + ? NO_MODELS_DEFINED_COMMENT + : models + .map((model) => { + return endent` + ${jsDocForModel(model)} + export const ${model.name}: $Types.${model.name} + ` + }) + .join('\n\n') + } + + // + // + // EXPORTS: PRISMA ENUMS + // EXPORTS: PRISMA ENUMS + // EXPORTS: PRISMA ENUMS + // EXPORTS: PRISMA ENUMS + // // - ${models - .map((model) => { - return endent` - ${jsDocForModel(model)} - export const ${model.name}: $Types.${model.name} - ` - }) - .join('\n\n')} + ${ + enums.length === 0 + ? NO_ENUMS_DEFINED_COMMENT + : enums + .map((enum_) => { + return endent` + ${jsDocForEnum(enum_)} + export const ${enum_.name}: $Types.${enum_.name} + ` + }) + .join('\n\n') + } + + ` +} + +function renderTypeScriptDeclarationForEnum(enum_: DMMF.DatamodelEnum): string { + return endent` + ${jsDocForEnum(enum_)} + interface ${enum_.name} { + name: '${enum_.name}' + description: ${enum_.documentation ? `'${enum_.documentation}'` : 'null'} + members: [${enum_.values.map((value) => `'${value.name}'`).join(', ')}] + } ` } diff --git a/src/generator/models/javascript.ts b/src/generator/models/javascript.ts index 01a17352b..89c00bff8 100644 --- a/src/generator/models/javascript.ts +++ b/src/generator/models/javascript.ts @@ -2,26 +2,28 @@ import { DMMF } from '@prisma/client/runtime' import endent from 'endent' import { chain } from 'lodash' import * as Nexus from 'nexus' -import { NexusListDef, NexusNonNullDef, NexusNullDef } from 'nexus/dist/core' +import { NexusEnumTypeConfig, NexusListDef, NexusNonNullDef, NexusNullDef } from 'nexus/dist/core' import { ModuleSpec } from '../types' import { fieldTypeToGraphQLType } from './declaration' -type Models = Record< - string, - Record< - string, - | { - name: string - // Any types required by Nexus API here. `unknown` does not work. - // eslint-disable-next-line - type: NexusNonNullDef | NexusListDef | NexusNullDef - description: string - } - | string - | null - > +type PrismaEnumName = string + +type PrismaModelName = string + +type PrismaModelOrEnumName = string + +type PrismaFieldName = string + +type PrismaModelFieldNameOrMetadataFieldName = string + +type NexusTypeDefConfigurations = Record< + PrismaModelOrEnumName, + NexusObjectTypeDefConfiguration | NexusEnumTypeDefConfiguration > +/** + * Create the module specification for the JavaScript runtime. + */ export function createModuleSpec(): ModuleSpec { return { fileName: 'index.js', @@ -30,15 +32,39 @@ export function createModuleSpec(): ModuleSpec { const ModelsGenerator = require('../generator/models') const dmmf = getPrismaClientDmmf() - const models = ModelsGenerator.JS.createModels(dmmf) + const models = ModelsGenerator.JS.createNexusTypeDefConfigurations(dmmf) module.exports = models `, } } -export function createModels(dmmf: DMMF.Document): Models { - const result = chain(dmmf.datamodel.models) +export function createNexusTypeDefConfigurations(dmmf: DMMF.Document): NexusTypeDefConfigurations { + return { + ...createNexusObjectTypeDefConfigurations(dmmf), + ...createNexusEnumTypeDefConfigurations(dmmf), + } +} + +type NexusObjectTypeDefConfigurations = Record + +type NexusObjectTypeDefConfiguration = Record< + PrismaModelFieldNameOrMetadataFieldName, + | { + name: PrismaFieldName + type: NexusNonNullDef | NexusListDef | NexusNullDef + description: string + } + // Metadata fields can be any of these + | string + | null +> + +/** + * Create Nexus object type definition configurations for Prisma models found in the given DMMF. + */ +function createNexusObjectTypeDefConfigurations(dmmf: DMMF.Document): NexusObjectTypeDefConfigurations { + return chain(dmmf.datamodel.models) .map((model) => { return { $name: model.name, @@ -47,7 +73,7 @@ export function createModels(dmmf: DMMF.Document): Models { .map((field) => { return { name: field.name, - type: fieldToNexusType(field), + type: prismaFieldToNexusType(field), description: field.documentation ?? null, } }) @@ -57,12 +83,11 @@ export function createModels(dmmf: DMMF.Document): Models { }) .keyBy('$name') .value() - return result } // Complex return type I don't really understand how to easily work with manually. // eslint-disable-next-line -export function fieldToNexusType(field: DMMF.Field) { +export function prismaFieldToNexusType(field: DMMF.Field) { const graphqlType = fieldTypeToGraphQLType(field) if (field.isList) { @@ -73,3 +98,27 @@ export function fieldToNexusType(field: DMMF.Field) { return Nexus.nullable(graphqlType) } } + +type AnyNexusEnumTypeConfig = NexusEnumTypeConfig + +type NexusEnumTypeDefConfigurations = Record + +type NexusEnumTypeDefConfiguration = AnyNexusEnumTypeConfig + +/** + * Create Nexus enum type definition configurations for Prisma enums found in the given DMMF. + */ +function createNexusEnumTypeDefConfigurations(dmmf: DMMF.Document): NexusEnumTypeDefConfigurations { + return chain(dmmf.datamodel.enums) + .map( + (enum_): AnyNexusEnumTypeConfig => { + return { + name: enum_.name, + description: enum_.documentation, + members: enum_.values.map((val) => val.name), + } + } + ) + .keyBy('name') + .value() +} diff --git a/tests/__helpers__.ts b/tests/__helpers__.ts index 0db819622..c38dcd125 100644 --- a/tests/__helpers__.ts +++ b/tests/__helpers__.ts @@ -3,12 +3,16 @@ import endent from 'endent' import execa from 'execa' import * as fs from 'fs-jetpack' import { FSJetpack } from 'fs-jetpack/types' +import { printSchema } from 'graphql' import { merge } from 'lodash' +import { core } from 'nexus' +import { AllNexusTypeDefs } from 'nexus/dist/core' import { PackageJson, TsConfigJson } from 'type-fest' import { generateRuntime } from '../src/generator/generate' +import * as ModelsGenerator from '../src/generator/models' import { ModuleSpec } from '../src/generator/types' -export function createSchema(content: string): string { +export function createPrismaSchema(content: string): string { return endent` datasource db { provider = "postgresql" @@ -27,8 +31,56 @@ export function createSchema(content: string): string { ` } -export async function generate(content: string): Promise<{ indexjs: string; indexdts: string }> { - const schema = createSchema(content) +/** + * Given a Prisma schema and Nexus type definitions return a GraphQL schema. + */ +export async function generateSchema({ + prismaSchema, + nexus, +}: { + /** + * Define a Prisma schema file + * + * Note datasource and generator blocks are taken care of automatically for you. + */ + prismaSchema: string + /** + * Define Nexus type definitions based on the Nexus Prisma configurations + * + * The configurations are typed as `any` to make them easy to work with. They ae not typesafe. Be careful. + */ + nexus(configurations: any): AllNexusTypeDefs[] +}) { + const dmmf = await PrismaSDK.getDMMF({ + datamodel: createPrismaSchema(prismaSchema), + }) + + const configurations = ModelsGenerator.JS.createNexusTypeDefConfigurations(dmmf) as any + + const { schema } = await core.generateSchema.withArtifacts({ + types: nexus(configurations), + }) + + const printedSchema = printSchema(schema) + + return ( + '\n' + + printedSchema + .replace( + endent` + type Query { + ok: Boolean! + } + `, + '' + ) + .trim() + + '\n' + ) +} + +export async function generateModules(content: string): Promise<{ indexjs: string; indexdts: string }> { + const schema = createPrismaSchema(content) const dmmf = await PrismaSDK.getDMMF({ datamodel: schema, diff --git a/tests/integration/__snapshots__/scalars.test.ts.snap b/tests/e2e/__snapshots__/e2e.test.ts.snap similarity index 95% rename from tests/integration/__snapshots__/scalars.test.ts.snap rename to tests/e2e/__snapshots__/e2e.test.ts.snap index 33c85339f..c4e182e24 100644 --- a/tests/integration/__snapshots__/scalars.test.ts.snap +++ b/tests/e2e/__snapshots__/e2e.test.ts.snap @@ -10,21 +10,28 @@ A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the \`da \\"\\"\\" scalar DateTime +enum E1 { + a + b + c +} + \\"\\"\\" The \`JSONObject\` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). \\"\\"\\" scalar Json -type Query { - ok: Boolean! -} - -type SomeObject { +type M1 { DateTimeManually: DateTime JsonManually: Json + e1: E1 someDateTimeField: DateTime! someJsonField: Json! } + +type Query { + ok: Boolean! +} " `; @@ -70,6 +77,7 @@ export interface NexusGenInputs { } export interface NexusGenEnums { + E1: \\"a\\" | \\"b\\" | \\"c\\" } export interface NexusGenScalars { @@ -83,13 +91,14 @@ export interface NexusGenScalars { } export interface NexusGenObjects { - Query: {}; - SomeObject: { // root type + M1: { // root type DateTimeManually?: NexusGenScalars['DateTime'] | null; // DateTime JsonManually?: NexusGenScalars['Json'] | null; // Json + e1?: NexusGenEnums['E1'] | null; // E1 someDateTimeField: NexusGenScalars['DateTime']; // DateTime! someJsonField: NexusGenScalars['Json']; // Json! } + Query: {}; } export interface NexusGenInterfaces { @@ -100,30 +109,32 @@ export interface NexusGenUnions { export type NexusGenRootTypes = NexusGenObjects -export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars +export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars & NexusGenEnums export interface NexusGenFieldTypes { - Query: { // field return type - ok: boolean; // Boolean! - } - SomeObject: { // field return type + M1: { // field return type DateTimeManually: NexusGenScalars['DateTime'] | null; // DateTime JsonManually: NexusGenScalars['Json'] | null; // Json + e1: NexusGenEnums['E1'] | null; // E1 someDateTimeField: NexusGenScalars['DateTime']; // DateTime! someJsonField: NexusGenScalars['Json']; // Json! } + Query: { // field return type + ok: boolean; // Boolean! + } } export interface NexusGenFieldTypeNames { - Query: { // field return type name - ok: 'Boolean' - } - SomeObject: { // field return type name + M1: { // field return type name DateTimeManually: 'DateTime' JsonManually: 'Json' + e1: 'E1' someDateTimeField: 'DateTime' someJsonField: 'Json' } + Query: { // field return type name + ok: 'Boolean' + } } export interface NexusGenArgTypes { @@ -139,7 +150,7 @@ export type NexusGenObjectNames = keyof NexusGenObjects; export type NexusGenInputNames = never; -export type NexusGenEnumNames = never; +export type NexusGenEnumNames = keyof NexusGenEnums; export type NexusGenInterfaceNames = never; diff --git a/tests/integration/scalars.test.ts b/tests/e2e/e2e.test.ts similarity index 80% rename from tests/integration/scalars.test.ts rename to tests/e2e/e2e.test.ts index 19a6db915..fe03138a3 100644 --- a/tests/integration/scalars.test.ts +++ b/tests/e2e/e2e.test.ts @@ -1,6 +1,7 @@ import * as Execa from 'execa' import stripAnsi from 'strip-ansi' -import { assertBuildPresent, createSchema, setupTestProject, TestProject } from '../__helpers__' +import { dump } from '../../src/helpers/utils' +import { assertBuildPresent, createPrismaSchema, setupTestProject, TestProject } from '../__helpers__' function setupTestProjectCase({ prismaSchema, @@ -83,24 +84,44 @@ beforeAll(() => { it('When bundled custom scalars are used the project type checks and generates expected GraphQL schema', () => { setupTestProjectCase({ testProject, + prismaSchema: createPrismaSchema(` + model M1 { + id String @id + someJsonField Json + someDateTimeField DateTime + } + + enum E1 { + a + b + c + } + `), main: ` - import { makeSchema, objectType } from 'nexus' - import { M1 } from 'nexus-prisma' + import { makeSchema, objectType, enumType } from 'nexus' + import { M1, E1 } from 'nexus-prisma' import * as customScalars from 'nexus-prisma/scalars' import * as Path from 'path' - const SomeObject = objectType({ - name: 'SomeObject', - definition(t) { - t.json('JsonManually') - t.dateTime('DateTimeManually') - t.field(M1.someJsonField.name, M1.someJsonField) - t.field(M1.someDateTimeField.name, M1.someDateTimeField) - }, - }) + const types = [ + customScalars, + enumType(E1), + objectType({ + name: M1.$name, + definition(t) { + t.field('e1', { + type: 'E1' + }) + t.json('JsonManually') + t.dateTime('DateTimeManually') + t.field(M1.someJsonField.name, M1.someJsonField) + t.field(M1.someDateTimeField.name, M1.someDateTimeField) + }, + }), + ] makeSchema({ - types: [customScalars, SomeObject], + types, shouldGenerateArtifacts: true, shouldExitAfterGenerateArtifacts: true, outputs: { @@ -112,22 +133,15 @@ it('When bundled custom scalars are used the project type checks and generates e // wait for output generation setTimeout(() => {}, 1000) `, - prismaSchema: createSchema(` - model M1 { - id String @id - someJsonField Json - someDateTimeField DateTime - } - `), }) // uncomment this to see dir (helpful to go there yourself and manually debug) - // console.log(testProject.tmpdir.cwd()) + console.log(testProject.tmpdir.cwd()) const results = runTestProject(testProject) // uncomment this to see the raw results (helpful for debugging) - // dump(results) + dump(results) expect(results.runFirstBuild.exitCode).toBe(2) @@ -135,10 +149,10 @@ it('When bundled custom scalars are used the project type checks and generates e /.*error TS2305: Module '"nexus-prisma"' has no exported member 'M1'.*/ ) expect(stripAnsi(results.runFirstBuild.stdout)).toMatch( - /.*error TS2339: Property 'json' does not exist on type 'ObjectDefinitionBlock<"SomeObject">'.*/ + /.*error TS2339: Property 'json' does not exist on type 'ObjectDefinitionBlock'.*/ ) expect(stripAnsi(results.runFirstBuild.stdout)).toMatch( - /.*error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock<"SomeObject">'.*/ + /.*error TS2339: Property 'dateTime' does not exist on type 'ObjectDefinitionBlock'.*/ ) expect(results.runReflectPrisma.exitCode).toBe(0) diff --git a/tests/integration/__snapshots__/enum.test.ts.snap b/tests/integration/__snapshots__/enum.test.ts.snap new file mode 100644 index 000000000..a4506e040 --- /dev/null +++ b/tests/integration/__snapshots__/enum.test.ts.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`When an enum is defined in the Prisma schema it can be projected into the GraphQL API 1`] = ` +" +enum Foo { + a +} +" +`; + +exports[`When an enum is defined with documentation in the Prisma schema it can be projected into the GraphQL API with that documentation 1`] = ` +" +\\"\\"\\"Some documentation\\"\\"\\" +enum Foo { + a +} +" +`; + +exports[`When an enum with multiple members is defined in the Prisma schema it and all its members can be projected into the GraphQL API 1`] = ` +" +enum Foo { + a + b + c +} +" +`; diff --git a/tests/integration/enum.test.ts b/tests/integration/enum.test.ts new file mode 100644 index 000000000..c968e3bd7 --- /dev/null +++ b/tests/integration/enum.test.ts @@ -0,0 +1,51 @@ +import endent from 'endent' +import { enumType } from 'nexus' +import { generateSchema } from '../__helpers__' + +it('When an enum is defined in the Prisma schema it can be projected into the GraphQL API', async () => { + const schema = await generateSchema({ + prismaSchema: endent` + enum Foo { + a + } + `, + nexus(configurations) { + return [enumType(configurations.Foo)] + }, + }) + + expect(schema).toMatchSnapshot() +}) + +it('When an enum with multiple members is defined in the Prisma schema it and all its members can be projected into the GraphQL API', async () => { + const schema = await generateSchema({ + prismaSchema: endent` + enum Foo { + a + b + c + } + `, + nexus(configurations) { + return [enumType(configurations.Foo)] + }, + }) + + expect(schema).toMatchSnapshot() +}) + +it('When an enum is defined with documentation in the Prisma schema it can be projected into the GraphQL API with that documentation', async () => { + const schema = await generateSchema({ + prismaSchema: endent` + /// Some documentation + enum Foo { + a + } + `, + nexus(configurations) { + return [enumType(configurations.Foo)] + }, + }) + + expect(schema).toMatchSnapshot() +}) diff --git a/tests/unit/__snapshots__/jsdoc.test.ts.snap b/tests/unit/__snapshots__/jsdoc.test.ts.snap deleted file mode 100644 index 43144af2a..000000000 --- a/tests/unit/__snapshots__/jsdoc.test.ts.snap +++ /dev/null @@ -1,442 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`When a model field has a documentation comment, then it is used for the JSDoc of that field and its $description field 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * Some documentation - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: string - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`When a model field has no documentation comment, then it gets the default JSDoc and its description field is null 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`When a model has a documentation comment, then it is used for the JSDoc of that model and its $description field 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * Some documentation - */ - interface SomeModel { - $name: 'SomeModel' - $description: 'Some documentation' - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * Some documentation - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`When a model has no documentation comment, then it gets the default JSDoc and its description field is null 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; diff --git a/tests/unit/__snapshots__/scalars.test.ts.snap b/tests/unit/__snapshots__/scalars.test.ts.snap deleted file mode 100644 index 57d93c42f..000000000 --- a/tests/unit/__snapshots__/scalars.test.ts.snap +++ /dev/null @@ -1,1158 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`A model field with type Boolean maps to GraphQL Boolean scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - /** - * ### 📔 Missing Field Documentation for \`foo\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * foo Boolean - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - foo: { - /** - * The name of this field. - */ - name: 'foo' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'Boolean'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type DateTime maps to GraphQL DateTime custom scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - /** - * ### 📔 Missing Field Documentation for \`foo\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * foo DateTime - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - foo: { - /** - * The name of this field. - */ - name: 'foo' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'DateTime'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type Float maps to GraphQL Float scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - /** - * ### 📔 Missing Field Documentation for \`foo\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * foo Float - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - foo: { - /** - * The name of this field. - */ - name: 'foo' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'Float'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type Int maps to GraphQL Int scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - /** - * ### 📔 Missing Field Documentation for \`foo\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * foo Int - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - foo: { - /** - * The name of this field. - */ - name: 'foo' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'Int'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type Int, attribute @id, maps to GraphQL ID scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id Int - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type Json maps to GraphQL Json custom scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - /** - * ### 📔 Missing Field Documentation for \`foo\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * foo Json - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - foo: { - /** - * The name of this field. - */ - name: 'foo' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'Json'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; - -exports[`A model field with type String, attribute @id, maps to GraphQL ID scalar 1`] = ` -"import * as Nexus from 'nexus' -import * as NexusCore from 'nexus/dist/core' - -// -// Types -// - -declare namespace $Types { - /** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ - interface SomeModel { - $name: 'SomeModel' - $description: null - /** - * ### 📔 Missing Field Documentation for \`id\` - * - * Get JSDoc documentation for this field automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a field add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model SomeModel { - * /// Lorem ipsum dolor sit amet. - * id String - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * model User { - * /// Identifier for a user. Will never change once set. - * /// More stable than the \`handle\` field which user - * /// _can_ change, but is not human-friendly. Prefer this - * /// for machine consumers but prefer \`handle\` for human - * /// visible things like URL slugs. - * id String @id - * } - * \`\`\` - */ - id: { - /** - * The name of this field. - */ - name: 'id' - - /** - * The type of this field. - */ - type: NexusCore.NexusNonNullDef<'ID'> - - /** - * The documentation of this field. - */ - description: undefined - } - } -} - - -// -// Exports -// - -/** - * ### 📔 Missing Model Documentation for \`SomeModel\` - * - * Get JSDoc documentation for this model automatically by documenting - * it in your Prisma Schema ✨! - * - * To document a model add a tripple slash comment above it. - * - * Learn more about Prisma Schema comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). - * - * #### ––––––––––––––––––––––––– Example 1 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// Lorem ipsum dolor sit amet... - * model SomeModel { - * id String @id - * } - * \`\`\` - * - * #### ––––––––––––––––––––––––– Example 2 ––––––––––––––––––––––––– - * - * \`\`\`prisma - * /// A user record. A user maps 1:1 with a person. Not - * /// to be confused with an \`Account\` which on person - * /// may have multiple of, all linked to a single \`User\`. - * model User { - * id String @id - * } - * \`\`\` - */ -export const SomeModel: $Types.SomeModel" -`; diff --git a/tests/unit/typescriptDeclarationFile/__snapshots__/enum.test.ts.snap b/tests/unit/typescriptDeclarationFile/__snapshots__/enum.test.ts.snap new file mode 100644 index 000000000..972995b2d --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/__snapshots__/enum.test.ts.snap @@ -0,0 +1,195 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`An enum maps to a Nexus enum type definition 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + // N/A –– You have not defined any enums in your Prisma schema file. + + // Enums + + /** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Enum + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * enum Foo { + * a + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ + interface Foo { + name: 'Foo' + description: null + members: ['a'] + } +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +// N/A –– You have not defined any enums in your Prisma schema file. + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +/** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Enum + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * enum Foo { + * a + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ +export const Foo: $Types.Foo" +`; + +exports[`When prisma enum has documentation then it is used for JSDoc and GraphQL enum description 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + // N/A –– You have not defined any enums in your Prisma schema file. + + // Enums + + /** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ + interface Foo { + name: 'Foo' + description: 'Some documentation' + members: ['a'] + } +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +// N/A –– You have not defined any enums in your Prisma schema file. + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +/** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ +export const Foo: $Types.Foo" +`; diff --git a/tests/unit/typescriptDeclarationFile/__snapshots__/enumDoc.test.ts.snap b/tests/unit/typescriptDeclarationFile/__snapshots__/enumDoc.test.ts.snap new file mode 100644 index 000000000..fb4b7e1e9 --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/__snapshots__/enumDoc.test.ts.snap @@ -0,0 +1,195 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`When an enum has a documentation comment, then it is used for the JSDoc of that enum and its $description field 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + // N/A –– You have not defined any enums in your Prisma schema file. + + // Enums + + /** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ + interface Foo { + name: 'Foo' + description: 'Some documentation' + members: ['a'] + } +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +// N/A –– You have not defined any enums in your Prisma schema file. + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +/** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ +export const Foo: $Types.Foo" +`; + +exports[`When an enum has no documentation comment, then it gets the default JSDoc and its description field is null 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + // N/A –– You have not defined any enums in your Prisma schema file. + + // Enums + + /** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Enum + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * enum Foo { + * a + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ + interface Foo { + name: 'Foo' + description: null + members: ['a'] + } +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +// N/A –– You have not defined any enums in your Prisma schema file. + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +/** + * Nexus \`enumType\` configuration based on the \`Foo\` enum in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Enum + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * enum Foo { + * a + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { enumType } from 'nexus' + * import { Foo } from 'nexus-prisma' + * + * enumType(Foo) + */ +export const Foo: $Types.Foo" +`; diff --git a/tests/unit/typescriptDeclarationFile/__snapshots__/modelDocumentation.test.ts.snap b/tests/unit/typescriptDeclarationFile/__snapshots__/modelDocumentation.test.ts.snap new file mode 100644 index 000000000..547eb9798 --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/__snapshots__/modelDocumentation.test.ts.snap @@ -0,0 +1,631 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`When a model field has a documentation comment, then it is used for the JSDoc of that field and its $description field 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: string + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`When a model field has no documentation comment, then it gets the default JSDoc and its description field is null 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`When a model has a documentation comment, then it is used for the JSDoc of that model and its $description field 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: 'Some documentation' + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * Some documentation + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`When a model has no documentation comment, then it gets the default JSDoc and its description field is null 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; diff --git a/tests/unit/typescriptDeclarationFile/__snapshots__/modelScalarFields.test.ts.snap b/tests/unit/typescriptDeclarationFile/__snapshots__/modelScalarFields.test.ts.snap new file mode 100644 index 000000000..c5daec97f --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/__snapshots__/modelScalarFields.test.ts.snap @@ -0,0 +1,1400 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`A model field with type Boolean maps to GraphQL Boolean scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.foo\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * foo Boolean + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.foo.name, SomeModel.foo) + * } + * }) + */ + foo: { + /** + * The name of this field. + */ + name: 'foo' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'Boolean'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type DateTime maps to GraphQL DateTime custom scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.foo\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * foo DateTime + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.foo.name, SomeModel.foo) + * } + * }) + */ + foo: { + /** + * The name of this field. + */ + name: 'foo' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'DateTime'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type Float maps to GraphQL Float scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.foo\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * foo Float + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.foo.name, SomeModel.foo) + * } + * }) + */ + foo: { + /** + * The name of this field. + */ + name: 'foo' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'Float'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type Int maps to GraphQL Int scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.foo\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * foo Int + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.foo.name, SomeModel.foo) + * } + * }) + */ + foo: { + /** + * The name of this field. + */ + name: 'foo' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'Int'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type Int, attribute @id, maps to GraphQL ID scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id Int + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type Json maps to GraphQL Json custom scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.foo\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * foo Json + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.foo.name, SomeModel.foo) + * } + * }) + */ + foo: { + /** + * The name of this field. + */ + name: 'foo' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'Json'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; + +exports[`A model field with type String, attribute @id, maps to GraphQL ID scalar 1`] = ` +"import * as Nexus from 'nexus' +import * as NexusCore from 'nexus/dist/core' + +// +// +// TYPES +// TYPES +// TYPES +// TYPES +// +// + +declare namespace $Types { + // Models + + /** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + interface SomeModel { + $name: 'SomeModel' + $description: null + /** + * Nexus \`t.field\` related configuration based on the \`SomeModel.id\` field in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * \`\`\`prisma + * model SomeModel { + * /// Lorem ipsum dolor sit amet. + * id String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ + id: { + /** + * The name of this field. + */ + name: 'id' + + /** + * The type of this field. + */ + type: NexusCore.NexusNonNullDef<'ID'> + + /** + * The documentation of this field. + */ + description: undefined + } + } + + // Enums + + // N/A –– You have not defined any models in your Prisma schema file. +} + + +// +// +// EXPORTS +// EXPORTS +// EXPORTS +// EXPORTS +// +// + +// +// +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// EXPORTS: PRISMA MODELS +// +// + +/** + * Nexus \`objectType\` related configuration based on the \`SomeModel\` model in your Prisma schema. + * + * ### ️⚠️ Missing Documentation for this Model + * + * Automatically ✨ enrich this JSDoc with information about your enum + * type by documenting it in your Prisma schema. For example: + * + * + * \`\`\`prisma + * /// Lorem ipsum dolor sit amet... + * model SomeModel { + * foo String + * } + * \`\`\` + * + * Learn more about Prisma Schema documentation comments [here](https://www.prisma.io/docs/concepts/components/prisma-schema#comments). + * + * @example + * + * import { objectType } from 'nexus' + * import { SomeModel } from 'nexus-prisma' + * + * objectType({ + * name: SomeModel.$name + * description: SomeModel.$description + * definition(t) { + * t.field(SomeModel.id.name, SomeModel.id) + * } + * }) + */ +export const SomeModel: $Types.SomeModel + +// +// +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// EXPORTS: PRISMA ENUMS +// +// + +// N/A –– You have not defined any models in your Prisma schema file." +`; diff --git a/tests/unit/typescriptDeclarationFile/enum.test.ts b/tests/unit/typescriptDeclarationFile/enum.test.ts new file mode 100644 index 000000000..73e6d68c5 --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/enum.test.ts @@ -0,0 +1,22 @@ +import { generateModules } from '../../__helpers__' + +it('An enum maps to a Nexus enum type definition', async () => { + const { indexdts } = await generateModules(` + enum Foo { + a + } + `) + + expect(indexdts).toMatchSnapshot() +}) + +it('When prisma enum has documentation then it is used for JSDoc and GraphQL enum description', async () => { + const { indexdts } = await generateModules(` + /// Some documentation + enum Foo { + a + } + `) + + expect(indexdts).toMatchSnapshot() +}) diff --git a/tests/unit/typescriptDeclarationFile/enumDoc.test.ts b/tests/unit/typescriptDeclarationFile/enumDoc.test.ts new file mode 100644 index 000000000..778f4124e --- /dev/null +++ b/tests/unit/typescriptDeclarationFile/enumDoc.test.ts @@ -0,0 +1,22 @@ +import { generateModules } from '../../__helpers__' + +it('When an enum has no documentation comment, then it gets the default JSDoc and its description field is null', async () => { + const { indexdts } = await generateModules(` + enum Foo { + a + } + `) + + expect(indexdts).toMatchSnapshot() +}) + +it('When an enum has a documentation comment, then it is used for the JSDoc of that enum and its $description field', async () => { + const { indexdts } = await generateModules(` + /// Some documentation + enum Foo { + a + } + `) + + expect(indexdts).toMatchSnapshot() +}) diff --git a/tests/unit/jsdoc.test.ts b/tests/unit/typescriptDeclarationFile/modelDocumentation.test.ts similarity index 80% rename from tests/unit/jsdoc.test.ts rename to tests/unit/typescriptDeclarationFile/modelDocumentation.test.ts index 953e69f91..947e4e446 100644 --- a/tests/unit/jsdoc.test.ts +++ b/tests/unit/typescriptDeclarationFile/modelDocumentation.test.ts @@ -1,7 +1,7 @@ -import { generate } from '../__helpers__' +import { generateModules } from '../../__helpers__' it('When a model has no documentation comment, then it gets the default JSDoc and its description field is null', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id } @@ -11,7 +11,7 @@ it('When a model has no documentation comment, then it gets the default JSDoc an }) it('When a model field has no documentation comment, then it gets the default JSDoc and its description field is null', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id } @@ -21,7 +21,7 @@ it('When a model field has no documentation comment, then it gets the default JS }) it('When a model has a documentation comment, then it is used for the JSDoc of that model and its $description field', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` /// Some documentation model SomeModel { id String @id @@ -32,7 +32,7 @@ it('When a model has a documentation comment, then it is used for the JSDoc of t }) it('When a model field has a documentation comment, then it is used for the JSDoc of that field and its $description field', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { /// Some documentation id String @id diff --git a/tests/unit/scalars.test.ts b/tests/unit/typescriptDeclarationFile/modelScalarFields.test.ts similarity index 77% rename from tests/unit/scalars.test.ts rename to tests/unit/typescriptDeclarationFile/modelScalarFields.test.ts index 20b2082a8..d1dfee60c 100644 --- a/tests/unit/scalars.test.ts +++ b/tests/unit/typescriptDeclarationFile/modelScalarFields.test.ts @@ -1,7 +1,7 @@ -import { generate } from '../__helpers__' +import { generateModules } from '../../__helpers__' it('A model field with type String, attribute @id, maps to GraphQL ID scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id } @@ -11,7 +11,7 @@ it('A model field with type String, attribute @id, maps to GraphQL ID scalar', a }) it('A model field with type Int, attribute @id, maps to GraphQL ID scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id Int @id } @@ -21,7 +21,7 @@ it('A model field with type Int, attribute @id, maps to GraphQL ID scalar', asyn }) it('A model field with type Int maps to GraphQL Int scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id foo Int @@ -32,7 +32,7 @@ it('A model field with type Int maps to GraphQL Int scalar', async () => { }) it('A model field with type Float maps to GraphQL Float scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id foo Float @@ -43,7 +43,7 @@ it('A model field with type Float maps to GraphQL Float scalar', async () => { }) it('A model field with type Boolean maps to GraphQL Boolean scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id foo Boolean @@ -54,7 +54,7 @@ it('A model field with type Boolean maps to GraphQL Boolean scalar', async () => }) it('A model field with type Json maps to GraphQL Json custom scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id foo Json @@ -65,7 +65,7 @@ it('A model field with type Json maps to GraphQL Json custom scalar', async () = }) it('A model field with type DateTime maps to GraphQL DateTime custom scalar', async () => { - const { indexdts } = await generate(` + const { indexdts } = await generateModules(` model SomeModel { id String @id foo DateTime diff --git a/yarn.lock b/yarn.lock index 73d75c7b2..a9923155b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1225,6 +1225,13 @@ ansi-escapes@^4.2.1, ansi-escapes@^4.3.1: dependencies: type-fest "^0.11.0" +ansi-red@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c" + integrity sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw= + dependencies: + ansi-wrap "0.1.0" + ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" @@ -1254,6 +1261,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansi-wrap@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -1309,7 +1321,7 @@ arg@^5.0.0: resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.0.tgz#a20e2bb5710e82950a516b3f933fee5ed478be90" integrity sha512-4P8Zm2H+BRS+c/xX1LrHw0qKpEhdlZjLCgWy+d78T9vqa2Z2SiD2wMrYuWIAFy5IZUD7nnNXroRttz+0RzlrzQ== -argparse@^1.0.7: +argparse@^1.0.10, argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -1383,6 +1395,13 @@ atob@^2.1.2: resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== +autolinker@~0.28.0: + version "0.28.1" + resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-0.28.1.tgz#0652b491881879f0775dace0cdca3233942a4e47" + integrity sha1-BlK0kYgYefB3XazgzcoyM5QqTkc= + dependencies: + gulp-header "^1.7.1" + aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" @@ -1795,6 +1814,11 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= +coffee-script@^1.12.4: + version "1.12.7" + resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.7.tgz#c05dae0cb79591d05b3070a8433a98c9a89ccc53" + integrity sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw== + collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -1884,6 +1908,23 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= +concat-stream@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +concat-with-sourcemaps@*: + version "1.1.0" + resolved "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e" + integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg== + dependencies: + source-map "^0.6.1" + configstore@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.1.tgz#d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96" @@ -2132,6 +2173,11 @@ detect-newline@^3.0.0: resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== +diacritics-map@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/diacritics-map/-/diacritics-map-0.1.0.tgz#6dfc0ff9d01000a2edf2865371cac316e94977af" + integrity sha1-bfwP+dAQAKLt8oZTccrDFulJd68= + diff-sequences@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" @@ -2500,6 +2546,13 @@ expand-brackets@^2.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + integrity sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc= + dependencies: + fill-range "^2.1.0" + expect@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/expect/-/expect-26.6.2.tgz#c6b996bf26bf3fe18b67b2d0f51fc981ba934417" @@ -2614,6 +2667,17 @@ file-entry-cache@^6.0.1: dependencies: flat-cache "^3.0.4" +fill-range@^2.1.0: + version "2.2.4" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565" + integrity sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q== + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^3.0.0" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -2906,11 +2970,31 @@ graphql@^15.5.0: resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.0.tgz#39d19494dbe69d1ea719915b578bf920344a69d5" integrity sha512-OmaM7y0kaK31NKG31q4YbD2beNYa6jBBKtMFT6gLYJljHLJr42IqJ8KX08u3Li/0ifzTU5HjmoOOrwa5BRLeDA== +gray-matter@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-2.1.1.tgz#3042d9adec2a1ded6a7707a9ed2380f8a17a430e" + integrity sha1-MELZrewqHe1qdwep7SOA+KF6Qw4= + dependencies: + ansi-red "^0.1.1" + coffee-script "^1.12.4" + extend-shallow "^2.0.1" + js-yaml "^3.8.1" + toml "^2.3.2" + growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= +gulp-header@^1.7.1: + version "1.8.12" + resolved "https://registry.yarnpkg.com/gulp-header/-/gulp-header-1.8.12.tgz#ad306be0066599127281c4f8786660e705080a84" + integrity sha512-lh9HLdb53sC7XIZOYzTXM4lFuXElv3EVkSDhsd7DoJBj7hm+Ni7D3qYbb+Rr8DuM8nRanBvkVO9d7askreXGnQ== + dependencies: + concat-with-sourcemaps "*" + lodash.template "^4.4.0" + through2 "^2.0.0" + har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" @@ -3270,6 +3354,13 @@ is-npm@^4.0.0: resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-4.0.0.tgz#c90dd8380696df87a7a6d823c20d0b12bbe3c84d" integrity sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig== +is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + integrity sha1-Afy7s5NGOlSPL0ZszhbezknbkI8= + dependencies: + kind-of "^3.0.2" + is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3277,6 +3368,11 @@ is-number@^3.0.0: dependencies: kind-of "^3.0.2" +is-number@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ== + is-number@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" @@ -3827,7 +3923,7 @@ js-tokens@^4.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.1: +js-yaml@^3.13.1, js-yaml@^3.8.1: version "3.14.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== @@ -3984,6 +4080,13 @@ latest-version@^5.0.0: dependencies: package-json "^6.3.0" +lazy-cache@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-2.0.2.tgz#b9190a4f913354694840859f8a8f7084d8822264" + integrity sha1-uRkKT5EzVGlIQIWfio9whNiCImQ= + dependencies: + set-getter "^0.1.0" + lazystream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" @@ -4017,6 +4120,16 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= +list-item@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/list-item/-/list-item-1.1.1.tgz#0c65d00e287cb663ccb3cb3849a77e89ec268a56" + integrity sha1-DGXQDih8tmPMs8s4Sad+iewmilY= + dependencies: + expand-range "^1.8.1" + extend-shallow "^2.0.1" + is-number "^2.1.0" + repeat-string "^1.5.2" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -4142,6 +4255,34 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-link@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/markdown-link/-/markdown-link-0.1.1.tgz#32c5c65199a6457316322d1e4229d13407c8c7cf" + integrity sha1-MsXGUZmmRXMWMi0eQinRNAfIx88= + +markdown-toc@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/markdown-toc/-/markdown-toc-1.2.0.tgz#44a15606844490314afc0444483f9e7b1122c339" + integrity sha512-eOsq7EGd3asV0oBfmyqngeEIhrbkc7XVP63OwcJBIhH2EpG2PzFcbZdhy1jutXSlRBBVMNXHvMtSr5LAxSUvUg== + dependencies: + concat-stream "^1.5.2" + diacritics-map "^0.1.0" + gray-matter "^2.1.0" + lazy-cache "^2.0.2" + list-item "^1.1.1" + markdown-link "^0.1.1" + minimist "^1.2.0" + mixin-deep "^1.1.3" + object.pick "^1.2.0" + remarkable "^1.7.1" + repeat-string "^1.6.1" + strip-color "^0.1.0" + +math-random@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.4.tgz#5dd6943c938548267016d4e34f057583080c514c" + integrity sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A== + merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -4245,7 +4386,7 @@ minizlib@^2.1.1: minipass "^3.0.0" yallist "^4.0.0" -mixin-deep@^1.2.0: +mixin-deep@^1.1.3, mixin-deep@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== @@ -4435,7 +4576,7 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.pick@^1.3.0: +object.pick@^1.2.0, object.pick@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= @@ -4825,6 +4966,15 @@ ramda@0.27.1: resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9" integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw== +randomatic@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.1.tgz#b776efc59375984e36c537b2f51a1f0aff0da1ed" + integrity sha512-TuDE5KxZ0J461RVjrJZCJc+J+zCkTb1MbH9AQUq68sMhOMcy9jLcb3BrZKgp9q9Ncltdg4QVqWrH02W2EFFVYw== + dependencies: + is-number "^4.0.0" + kind-of "^6.0.0" + math-random "^1.0.1" + rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" @@ -4859,7 +5009,7 @@ read-pkg@^5.2.0: parse-json "^5.0.0" type-fest "^0.6.0" -readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.3.7: +readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.2.2, readable-stream@^2.3.7, readable-stream@~2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -4915,6 +5065,14 @@ registry-url@^5.0.0: dependencies: rc "^1.2.8" +remarkable@^1.7.1: + version "1.7.4" + resolved "https://registry.yarnpkg.com/remarkable/-/remarkable-1.7.4.tgz#19073cb960398c87a7d6546eaa5e50d2022fcd00" + integrity sha512-e6NKUXgX95whv7IgddywbeN/ItCkWbISmc2DiqHJb0wTrqZIexqdco5b8Z3XZoo/48IdNVKM9ZCvTPJ4F5uvhg== + dependencies: + argparse "^1.0.10" + autolinker "~0.28.0" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -4925,7 +5083,7 @@ repeat-element@^1.1.2: resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== -repeat-string@^1.6.1: +repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= @@ -5150,6 +5308,13 @@ set-blocking@^2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= +set-getter@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/set-getter/-/set-getter-0.1.0.tgz#d769c182c9d5a51f409145f2fba82e5e86e80376" + integrity sha1-12nBgsnVpR9AkUXy+6guXoboA3Y= + dependencies: + to-object-path "^0.3.0" + set-value@^2.0.0, set-value@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" @@ -5479,6 +5644,11 @@ strip-bom@^4.0.0: resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== +strip-color@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/strip-color/-/strip-color-0.1.0.tgz#106f65d3d3e6a2d9401cac0eb0ce8b8a702b4f7b" + integrity sha1-EG9l09PmotlAHKwOsM6LinArT3s= + strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" @@ -5630,6 +5800,14 @@ throat@^5.0.0: resolved "https://registry.yarnpkg.com/throat/-/throat-5.0.0.tgz#c5199235803aad18754a667d659b5e72ce16764b" integrity sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA== +through2@^2.0.0: + version "2.0.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + tmp@0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" @@ -5684,6 +5862,11 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +toml@^2.3.2: + version "2.3.6" + resolved "https://registry.yarnpkg.com/toml/-/toml-2.3.6.tgz#25b0866483a9722474895559088b436fd11f861b" + integrity sha512-gVweAectJU3ebq//Ferr2JUY4WKSDe5N+z0FvjDncLGyHmIDoxgY/2Ie4qfEIDm4IS7OA6Rmdm7pdEEdMcV/xQ== + touch@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b" @@ -5828,6 +6011,11 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + typescript@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" @@ -6122,6 +6310,11 @@ xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== +xtend@~4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + y18n@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"