Skip to content

Commit

Permalink
add test for nullable connections and make build work without docker
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Jul 18, 2023
1 parent 0011046 commit 62662fc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/plugin-prisma-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"scripts": {
"generate": "prisma migrate reset -f && ts-node --transpile-only tests/examples/codegen/generator.ts && pnpm schema",
"generate": "prisma generate && ts-node --transpile-only tests/examples/codegen/generator.ts && pnpm schema",
"schema": "ts-node --transpile-only tests/examples/codegen/schema/index.ts && ts-node --transpile-only tests/examples/crud/schema/index.ts",
"type": "tsc --project tsconfig.type.json",
"build": "pnpm build:clean && pnpm build:cjs && pnpm build:dts && pnpm build:esm",
Expand Down
14 changes: 14 additions & 0 deletions packages/plugin-prisma/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ type Query {
namedUnion: [NamedUnion]
node(id: ID!): Node
nodes(ids: [ID!]!): [Node]!
nullableUserConnection(after: ID, before: ID, first: Int, last: Int): QueryNullableUserConnection
post(id: ID!): Post
posts: [Post!]!
postsBigIntCursor(after: ID, before: ID, first: Int, last: Int): QueryPostsBigIntCursorConnection!
Expand Down Expand Up @@ -212,6 +213,19 @@ type QueryNamedConnectionEdge {
node: Named!
}
type QueryNullableUserConnection {
edges: [QueryNullableUserConnectionEdge]!
pageInfo: PageInfo!
\\"\\"\\"default totalCount field for all connections\\"\\"\\"
totalCount: Int!
}
type QueryNullableUserConnectionEdge {
cursor: String!
node: User!
}
type QueryPostsBigIntCursorConnection {
edges: [QueryPostsBigIntCursorConnectionEdge]!
pageInfo: PageInfo!
Expand Down
14 changes: 14 additions & 0 deletions packages/plugin-prisma/tests/example/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,20 @@ builder.queryType({
errors: {},
resolve: async (query, parent, args) => prisma.user.findMany({ ...query }),
}),
nullableUserConnection: t.prismaConnection({
type: 'User',
nullable: true,
cursor: 'id',
defaultSize: 10,
maxSize: 15,
resolve: async (query, parent, args) => {
if (args.first === 0) {
return null;
}

return prisma.user.findMany({ ...query });
},
}),
named: t.field({
type: [Named],
nullable: {
Expand Down

1 comment on commit 62662fc

@vercel
Copy link

@vercel vercel bot commented on 62662fc Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.