-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: control rejectOnNotFound client setting (#135)
- Loading branch information
1 parent
f9e2f2e
commit 01daf38
Showing
9 changed files
with
206 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
tests/integration/__snapshots__/rejectOnNotFound.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ignores global rejectOnNotFound Prisma Client settings: graphqlOperationExecutionResult 1`] = ` | ||
Object { | ||
"data": Object { | ||
"users": Array [ | ||
Object { | ||
"id": "user1", | ||
"profile": null, | ||
}, | ||
], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`ignores global rejectOnNotFound Prisma Client settings: graphqlSchemaSDL 1`] = ` | ||
" | ||
type Query { | ||
users: [User!]! | ||
} | ||
type User { | ||
id: ID! | ||
profile: Profile | ||
} | ||
type Profile { | ||
id: ID! | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import gql from 'graphql-tag' | ||
import { objectType, queryType } from 'nexus' | ||
import { testIntegration } from '../__helpers__/testers' | ||
|
||
testIntegration({ | ||
description: 'ignores global rejectOnNotFound Prisma Client settings', | ||
datasourceSchema: ` | ||
model User { | ||
id String @id | ||
profile Profile? @relation(fields: [profileId], references: [id]) | ||
profileId String? | ||
} | ||
model Profile { | ||
id String @id | ||
user User? | ||
} | ||
`, | ||
apiSchema({ User, Profile }) { | ||
return [ | ||
queryType({ | ||
definition(t) { | ||
t.nonNull.list.nonNull.field('users', { | ||
type: 'User', | ||
resolve(_, __, ctx) { | ||
return ctx.prisma.user.findMany() | ||
}, | ||
}) | ||
}, | ||
}), | ||
objectType({ | ||
name: User.$name, | ||
definition(t) { | ||
t.field(User.id) | ||
t.field(User.profile) | ||
}, | ||
}), | ||
objectType({ | ||
name: Profile.$name, | ||
definition(t) { | ||
t.field(Profile.id) | ||
}, | ||
}), | ||
] | ||
}, | ||
setupPrismaClient(prismaClientPackage) { | ||
// This global setting should have no effect on Nexus Prisma | ||
return new prismaClientPackage.PrismaClient({ | ||
rejectOnNotFound: true, | ||
}) | ||
}, | ||
async setup(prisma) { | ||
await prisma.user.create({ | ||
data: { | ||
id: 'user1', | ||
}, | ||
}) | ||
}, | ||
apiClientQuery: gql` | ||
query { | ||
users { | ||
id | ||
profile { | ||
id | ||
} | ||
} | ||
} | ||
`, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
01daf38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: