Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update zod to 3.24.0 #8

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/cattery-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"@gqloom/zod": "workspace:*",
"graphql": "^16.8.1",
"graphql-yoga": "^5.6.0",
"zod": "^3.22.4"
"zod": "^3.24.0"
}
}
2 changes: 1 addition & 1 deletion examples/middlewares/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"graphql": "^16.8.1",
"graphql-yoga": "^5.6.0",
"valibot": "1.0.0-beta.7",
"zod": "^3.22.4"
"zod": "^3.24.0"
}
}
2 changes: 1 addition & 1 deletion examples/subscriptions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"graphql": "^16.8.1",
"graphql-yoga": "^5.6.0",
"valibot": "1.0.0-beta.7",
"zod": "^3.22.4"
"zod": "^3.24.0"
}
}
6 changes: 3 additions & 3 deletions packages/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"license": "MIT",
"peerDependencies": {
"@gqloom/core": ">= 0.5.0",
"prisma": ">= 5.0.0",
"graphql": ">= 16.8.0"
"graphql": ">= 16.8.0",
"prisma": ">= 5.0.0"
},
"devDependencies": {
"@gqloom/core": "workspace:*",
Expand All @@ -53,7 +53,7 @@
"@prisma/client": "5.20.0",
"graphql-yoga": "^5.6.0",
"prisma": "^5.20.0",
"zod": "^3.22.4"
"zod": "^3.24.0"
},
"homepage": "https://gqloom.dev/",
"repository": {
Expand Down
127 changes: 73 additions & 54 deletions packages/prisma/test/bobbin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type StandardSchemaV1, loom, weave } from "@gqloom/core"
import { asInputArgs, zodSilk } from "@gqloom/zod"
import { ZodWeaver, asInputArgs } from "@gqloom/zod"
import { PrismaClient } from "@prisma/client"
import { printSchema, printType } from "graphql"
import { createYoga } from "graphql-yoga"
Expand Down Expand Up @@ -127,7 +127,7 @@ describe("PrismaModelBobbin", () => {
`)
})

it("should be able to resolve a relationField", { retry: 20 }, async () => {
it("should be able to resolve a relationField", async () => {
const response = await yoga.fetch("http://localhost/graphql", {
method: "POST",
headers: {
Expand Down Expand Up @@ -155,6 +155,7 @@ describe("PrismaModelBobbin", () => {

if (response.status !== 200) throw new Error("unexpected")
const json = await response.json()
// if (!json?.data) return
expect(json).toMatchObject({
data: {
users: [
Expand Down Expand Up @@ -204,17 +205,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
countUser: UserBobbin.countQuery({
input: zodSilk(
z
.object({
where: UserWhereInput,
})
.superRefine(asInputArgs())
),
input: z
.object({
where: UserWhereInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -265,13 +264,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
findFirstUser: UserBobbin.findFirstQuery({
input: zodSilk.input({
where: UserWhereInput.optional(),
}),
input: z
.object({
where: UserWhereInput.optional(),
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -323,13 +324,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
findManyUser: UserBobbin.findManyQuery({
input: zodSilk.input({
where: UserWhereInput.optional(),
}),
input: z
.object({
where: UserWhereInput.optional(),
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -381,13 +384,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
findUniqueUser: UserBobbin.findUniqueQuery({
input: zodSilk.input({
where: UserWhereInput,
}),
input: z
.object({
where: UserWhereInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -439,13 +444,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
createUser: UserBobbin.createMutation({
input: zodSilk.input({
data: UserCreateInput,
}),
input: z
.object({
data: UserCreateInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -495,12 +502,14 @@ describe("PrismaModelBobbin", () => {
})
const r = resolver.of(g.User, {
createManyUser: UserBobbin.createManyMutation({
input: zodSilk.input({
data: UserCreateManyInput.array(),
}),
input: z
.object({
data: UserCreateManyInput.array(),
})
.superRefine(asInputArgs()),
}),
})
const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -555,13 +564,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
deleteUser: UserBobbin.deleteMutation({
input: zodSilk.input({
where: UserDeleteInput,
}),
input: z
.object({
where: UserDeleteInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -611,13 +622,15 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
deleteManyUser: UserBobbin.deleteManyMutation({
input: zodSilk.input({
where: UserDeleteManyInput,
}),
input: z
.object({
where: UserDeleteManyInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -677,14 +690,16 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
updateUser: UserBobbin.updateMutation({
input: zodSilk.input({
data: UserUpdateInput,
where: UserWhereInput,
}),
input: z
.object({
data: UserUpdateInput,
where: UserWhereInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -744,14 +759,16 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
updateManyUser: UserBobbin.updateManyMutation({
input: zodSilk.input({
data: UserUpdateManyInput,
where: UserWhereInput,
}),
input: z
.object({
data: UserUpdateManyInput,
where: UserWhereInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down Expand Up @@ -815,15 +832,17 @@ describe("PrismaModelBobbin", () => {

const r = resolver.of(g.User, {
upsertUser: UserBobbin.upsertMutation({
input: zodSilk.input({
where: UserWhereUniqueInput,
create: UserUpsertInput,
update: UserUpsertInput,
}),
input: z
.object({
where: UserWhereUniqueInput,
create: UserUpsertInput,
update: UserUpsertInput,
})
.superRefine(asInputArgs()),
}),
})

const schema = weave(r)
const schema = weave(ZodWeaver, r)
expect(printSchema(schema)).toMatchInlineSnapshot(`
"type User {
id: ID!
Expand Down
11 changes: 1 addition & 10 deletions packages/valibot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
isNonNullType,
isObjectType,
} from "graphql"
import * as v from "valibot"
import type * as v from "valibot"
import { type AsObjectTypeMetadata, ValibotMetadataCollector } from "./metadata"
import type {
EnumLike,
Expand Down Expand Up @@ -298,15 +298,6 @@ export class ValibotWeaver {
)
}

static parse<TSchema extends GenericSchemaOrAsync>(
this: TSchema,
input: unknown
): Promise<v.InferOutput<TSchema>> | v.InferOutput<TSchema> {
return this.async
? v.parseAsync(this, input)
: v.parse(this as v.GenericSchema, input)
}

static getGraphQLType(schema: GenericSchemaOrAsync): GraphQLOutputType {
return ValibotWeaver.toNullableGraphQLType(schema)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/zod/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## next (YYYY-MM-DD)

* update zod version to 3.24.0 and remove unnecessary functions

## 0.5.0 (2024-12-03)

* Chore: update `@standard-schema/spec` to 1.0.0-beta.4
Expand Down
6 changes: 3 additions & 3 deletions packages/zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"author": "xcfox",
"license": "MIT",
"peerDependencies": {
"graphql": ">= 16.8.0",
"@gqloom/core": ">= 0.5.0",
"zod": ">= 3.0.0"
"graphql": ">= 16.8.0",
"zod": ">= 3.24.0"
},
"files": ["dist"],
"devDependencies": {
"@gqloom/core": "workspace:*",
"zod": "^3.22.4"
"zod": "^3.24.0"
},
"homepage": "https://gqloom.dev/",
"repository": {
Expand Down
Loading
Loading