diff --git a/preview.json b/preview.json deleted file mode 100644 index ca70a252..00000000 --- a/preview.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "kind": "ok", - "type": "dry_run", - "data": { - "report": { - "stops": [], - "errors": [], - "passes": [ - { - "details": {}, - "summary": "You must have npm auth setup to publish to the registrty", - "code": "npm_auth_not_setup" - }, - { "details": {}, "summary": "You must be on the trunk branch", "code": "must_be_on_trunk" }, - { - "details": {}, - "summary": "A preview release requires the commit to have no existing stable or preview release.", - "code": "preview_on_commit_with_preview_and_or_stable" - }, - { - "details": {}, - "summary": "A preview release must have at least one commit since the last preview", - "code": "series_empty" - }, - { - "details": {}, - "summary": "A preview release must have at least one semantic commit", - "code": "series_only_has_meaningless_commits" - } - ] - }, - "release": { - "bumpType": "minor", - "version": { - "version": "0.15.0-next.7", - "vprefix": false, - "major": 0, - "minor": 15, - "patch": 0, - "preRelease": { "buildNum": 7, "identifier": "next" } - } - }, - "commits": [ - { - "raw": "feat: enable configuring scalars (#712)", - "parsed": { - "typeKind": "feat", - "type": "feat", - "scope": null, - "description": "enable configuring scalars (#712)", - "body": null, - "footers": [], - "breakingChange": null, - "completesInitialDevelopment": false - } - } - ], - "changelog": "#### BREAKING CHANGES\n\n- 34a2bdf support prisma 2 (#692)\n- cdfcda2 revert to old pagination model (#699)\n- 0c03826 support Prisma Beta 8 (#688)\n- ea8c5fc support prisma beta 7 (#683)\n- 541996b put `t.crud` behind an experimental flag (#682)\n\n#### Features\n\n- fe9611e enable configuring scalars (#712)\n- 18e017d configurable pagination, prisma option (#709)\n- cd3b5c9 relative @prisma/client import when path given (#704)\n- 34a2bdf (breaking) support prisma 2 (#692)\n- cdfcda2 (breaking) revert to old pagination model (#699)\n- a08b741 warn if t.crud is used but not enabled (#691)\n- 0703fb7 partially support Json type (#690)\n- 0c03826 (breaking) support Prisma Beta 8 (#688)\n- 9569bd6 support custom resolvers (#674)\n- 7c5f4b8 forward nexus plugins into t.model and t.crud (#687)\n- 6d44cdd support model without ids, compound ids and uniques (#686)\n- ea8c5fc (breaking) support prisma beta 7 (#683)\n- 541996b (breaking) put `t.crud` behind an experimental flag (#682)\n\n#### Fixes\n\n- b089997 automated releases\n- 2cabc65 convert nulls to undefined for non-nullable Prisma fields (#695)\n- 061df60 do not require react types (#700)\n- c63b8ae support model with a single id field (#696)\n\n#### Improvements\n\n- c9ee9bb test: remove verbose snapshots (#705)\n- a5671d0 improve: remove photon check (#693)\n\n#### Chores\n\n- 81a53b7 prettier format\n- ffe63d9 setup automated preview releases\n- b67b73b sync lock file\n- f903d5a update examples\n" - } -} diff --git a/src/schema/builder.ts b/src/schema/builder.ts index 2bc4b033..bcbb9590 100644 --- a/src/schema/builder.ts +++ b/src/schema/builder.ts @@ -26,7 +26,7 @@ import { proxifyModelFunction, proxifyPublishers } from './proxifier' import { Publisher } from './publisher' import * as Typegen from './typegen' import { - assertPhotonInContext, + assertPrismaClientInContext, GlobalComputedInputs, Index, indexBy, @@ -94,10 +94,10 @@ const dmmfListFieldTypeToNexus = (fieldType: DmmfTypes.SchemaField['outputType'] type PrismaClientFetcher = (ctx: Nexus.core.GetGen<'context'>) => any export interface Options { - // TODO return type should be Photon + // TODO return type should be Prisma Client /** * nexus-prisma will call this to get a reference to an instance of the Prisma Client. - * The function is passed the context object. Typically a Photon instance will + * The function is passed the context object. Typically a Prisma Client instance will * be available on the context to support your custom resolvers. Therefore the * default getter returns `ctx.prisma`. */ @@ -267,9 +267,9 @@ export class SchemaBuilder { this.wasCrudUsedButDisabled = false this.getPrismaClient = (ctx: any) => { - const photon = config.prismaClient(ctx) - assertPhotonInContext(photon) - return photon + const prismaClient = config.prismaClient(ctx) + assertPrismaClientInContext(prismaClient) + return prismaClient } if (config.shouldGenerateArtifacts) { Typegen.generateSync({ @@ -322,7 +322,7 @@ export class SchemaBuilder { const schemaArgsIndex = indexBy(mappedField.field.args, 'name') const originalResolve: GraphQLFieldResolver = (_root, args, ctx, info) => { - const photon = this.getPrismaClient(ctx) + const prismaClient = this.getPrismaClient(ctx) if ( typeName === 'Mutation' && (!isEmptyObject(publisherConfig.locallyComputedInputs) || @@ -343,7 +343,7 @@ export class SchemaBuilder { args = this.paginationStrategy.resolve(args) - return photon[mappedField.photonAccessor][mappedField.operation](args) + return prismaClient[mappedField.prismaClientAccessor][mappedField.operation](args) } const fieldConfig = this.buildFieldConfig({ @@ -513,12 +513,12 @@ export class SchemaBuilder { ) } - const photon = this.getPrismaClient(ctx) + const prismaClient = this.getPrismaClient(ctx) args = transformNullsToUndefined(args, schemaArgsIndex, this.dmmf) args = this.paginationStrategy.resolve(args) - return photon[lowerFirst(mapping.model)] + return prismaClient[lowerFirst(mapping.model)] .findOne({ where: Constraints.buildWhereUniqueInput(root, uniqueIdentifiers), }) @@ -609,7 +609,7 @@ export class SchemaBuilder { argsFromMutationField({ publisherConfig, field }: FieldConfigData): CustomInputArg[] { return field.args.map((arg) => { - const photonInputType = this.dmmf.getInputType(arg.inputType.type) + const prismaClientInputType = this.dmmf.getInputType(arg.inputType.type) /* Since globallyComputedInputs were already filtered during schema transformation, at this point we just need to filter at the resolver-level. @@ -617,10 +617,12 @@ export class SchemaBuilder { return { arg, type: { - ...photonInputType, + ...prismaClientInputType, fields: publisherConfig.locallyComputedInputs - ? photonInputType.fields.filter((field) => !(field.name in publisherConfig.locallyComputedInputs)) - : photonInputType.fields, + ? prismaClientInputType.fields.filter( + (field) => !(field.name in publisherConfig.locallyComputedInputs) + ) + : prismaClientInputType.fields, }, } }) @@ -738,28 +740,28 @@ export class SchemaBuilder { fieldName: string, graphQLTypeName: string ): DmmfTypes.InputType { - const photonObject = this.dmmf.getInputType(inputTypeName) + const prismaClientObject = this.dmmf.getInputType(inputTypeName) // If the publishing for this field feature (filtering, ordering, ...) // has not been tailored then we may simply pass through the backing // version as-is. // if (fieldWhitelist === true) { - return photonObject + return prismaClientObject } // REFACTOR use an intersection function const whitelistedFieldNames = Object.keys(fieldWhitelist) - const userExposedObjectFields = photonObject.fields.filter((field) => + const userExposedObjectFields = prismaClientObject.fields.filter((field) => whitelistedFieldNames.includes(field.name) ) - const uniqueName = photonObject.isWhereType + const uniqueName = prismaClientObject.isWhereType ? this.argsNamingStrategy.whereInput(graphQLTypeName, fieldName) : this.argsNamingStrategy.orderByInput(graphQLTypeName, fieldName) return { - ...photonObject, + ...prismaClientObject, name: uniqueName, fields: userExposedObjectFields, } diff --git a/src/schema/dmmf/transformer.ts b/src/schema/dmmf/transformer.ts index 5c7dee93..081ad851 100644 --- a/src/schema/dmmf/transformer.ts +++ b/src/schema/dmmf/transformer.ts @@ -3,7 +3,7 @@ import { paginationStrategies, PaginationStrategy } from '../pagination' import { GlobalComputedInputs, GlobalMutationResolverParams, LocalComputedInputs } from '../utils' import { DmmfDocument } from './DmmfDocument' import { DmmfTypes } from './DmmfTypes' -import { getPhotonDmmf } from './utils' +import { getPrismaClientDmmf } from './utils' export type TransformOptions = { globallyComputedInputs?: GlobalComputedInputs @@ -11,9 +11,9 @@ export type TransformOptions = { } export const getTransformedDmmf = ( - photonClientPackagePath: string, + prismaClientPackagePath: string, options?: TransformOptions -): DmmfDocument => new DmmfDocument(transform(getPhotonDmmf(photonClientPackagePath), options)) +): DmmfDocument => new DmmfDocument(transform(getPrismaClientDmmf(prismaClientPackagePath), options)) const addDefaultOptions = (givenOptions?: TransformOptions): Required => ({ globallyComputedInputs: {}, @@ -84,7 +84,7 @@ function transformSchema( /** * Conversion from a Prisma Client arg type to a GraphQL arg type using * heuristics. A conversion is needed because GraphQL does not - * support union types on args, but Photon does. + * support union types on args, but Prisma Client does. */ function transformArg(arg: DMMF.SchemaArg): DmmfTypes.SchemaArg { // FIXME: *Enum*Filter are currently empty @@ -222,7 +222,7 @@ function transformInputType( } /** - * Make the "return type" property type always be a string. In Photon + * Make the "return type" property type always be a string. In Prisma Client * it is allowed to be a nested structured object but we want only the * reference-by-name form. * diff --git a/src/schema/dmmf/utils.ts b/src/schema/dmmf/utils.ts index 78c4b9c2..5cdac1e1 100644 --- a/src/schema/dmmf/utils.ts +++ b/src/schema/dmmf/utils.ts @@ -1,6 +1,6 @@ import { DMMF } from '@prisma/client/runtime' -export const getPhotonDmmf = (packagePath: string): DMMF.Document => { +export const getPrismaClientDmmf = (packagePath: string): DMMF.Document => { let dmmf: undefined | DMMF.Document = undefined try { diff --git a/src/schema/mapping.ts b/src/schema/mapping.ts index c15003c2..eab0484e 100644 --- a/src/schema/mapping.ts +++ b/src/schema/mapping.ts @@ -6,7 +6,7 @@ interface BaseMappedField { field: string operation: OperationName model: string - photonAccessor: string + prismaClientAccessor: string } export interface MappedField extends Omit { @@ -22,7 +22,7 @@ const buildField = (mapping: DmmfTypes.Mapping, operation: OperationName): BaseM operation, field: mapping[operation]!, model: mapping.model, - photonAccessor: lowerFirst(mapping.model), + prismaClientAccessor: lowerFirst(mapping.model), } } diff --git a/src/schema/utils.ts b/src/schema/utils.ts index 5a526934..7b65aea3 100644 --- a/src/schema/utils.ts +++ b/src/schema/utils.ts @@ -97,7 +97,7 @@ export function dmmfFieldToNexusFieldConfig(param: { } } -export function assertPhotonInContext(prismaClient: any) { +export function assertPrismaClientInContext(prismaClient: any) { if (!prismaClient) { throw new Error('Could not find Prisma Client JS in context (ctx.prisma)') }