Skip to content

Commit

Permalink
refactor(valibot): consolidate imports from @gqloom/valibot
Browse files Browse the repository at this point in the history
  • Loading branch information
xcfox committed Dec 3, 2024
1 parent 8db2428 commit 7b80008
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 47 deletions.
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ The design of GQLoom is inspired by [tRPC](https://trpc.io/), [TypeGraphQL](http

## Features

- 🚀 GraphQL: flexible and efficient, reducing redundant data transfers;
- 🔒 Robust type safety: enjoy intelligent hints at development time to detect potential problems at compile time;
- 🔋 Ready to go: middleware, contexts, subscriptions, federated graphs are ready to go;
- 🔮 No extra magic: no decorators, no metadata and reflection, no code generation, you just need JavaScript/TypeScript;
- 🧩 Familiar schema libraries: use the schema libraries you already know (Zod, Yup, Valibot) to build GraphQL Schema and validate inputs;
- 🧑‍💻 Develop happily: highly readable and semantic APIs designed to keep your code tidy;
* 🚀 GraphQL: flexible and efficient, reducing redundant data transfers;
* 🔒 Robust type safety: enjoy intelligent hints at development time to detect potential problems at compile time;
* 🔋 Ready to go: middleware, contexts, subscriptions, federated graphs are ready to go;
* 🔮 No extra magic: no decorators, no metadata and reflection, no code generation, you just need JavaScript/TypeScript;
* 🧩 Familiar schema libraries: use the schema libraries you already know (Zod, Yup, Valibot) to build GraphQL Schema and validate inputs;
* 🧑‍💻 Develop happily: highly readable and semantic APIs designed to keep your code tidy;

## Hello World

```ts
import { resolver, query, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { resolver, query, weave, ValibotWeaver } from "@gqloom/valibot"
import * as v from "valibot"

const helloResolver = resolver({
Expand All @@ -43,22 +42,26 @@ See [Getting Started](https://gqloom.dev/guide/getting-started.html) to learn ho

## In this Repository

- [GQLoom Core](./packages/core/README.md): GraphQL Loom Core Features;
* [GQLoom Core](./packages/core/README.md): GraphQL Loom Core Features;

- [GQLoom Federation](./packages/federation/README.md): Provides GQLoom support for Apollo Federation;
* [GQLoom Federation](./packages/federation/README.md): Provides GQLoom support for Apollo Federation;

- [GQLoom Mikro ORM](./packages/mikro-orm/README.md): GQLoom integration with Mikro ORM;
* [GQLoom Mikro ORM](./packages/mikro-orm/README.md): GQLoom integration with Mikro ORM;

- [GQLoom Prisma](./packages/prisma/README.md): GQLoom integration with Prisma;
* [GQLoom Prisma](./packages/prisma/README.md): GQLoom integration with Prisma;

- [GQLoom Valibot](./packages/valibot/README.md): GQLoom integration with Valibot;
* [GQLoom Valibot](./packages/valibot/README.md): GQLoom integration with Valibot;

- [GQLoom Yup](./packages/yup/README.md): GQLoom integration with Yup;
* [GQLoom Yup](./packages/yup/README.md): GQLoom integration with Yup;

- [GQLoom Zod](./packages/zod/README.md): GQLoom integration with Zod;
* [GQLoom Zod](./packages/zod/README.md): GQLoom integration with Zod;

[license-image]: https://img.shields.io/badge/License-MIT-brightgreen.svg?style=flat-square

[license-url]: https://opensource.org/licenses/MIT

[npm-image]: https://img.shields.io/npm/v/%40gqloom%2Fcore.svg?style=flat-square

[npm-url]: https://www.npmjs.com/package/@gqloom/core

[downloads-image]: https://img.shields.io/npm/dm/%40gqloom%2Fcore.svg?style=flat-square
10 changes: 8 additions & 2 deletions examples/cattery-valibot/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { createServer } from "node:http"
import { field, mutation, query, resolver, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import {
ValibotWeaver,
field,
mutation,
query,
resolver,
weave,
} from "@gqloom/valibot"
import { createYoga } from "graphql-yoga"
import * as v from "valibot"

Expand Down
3 changes: 1 addition & 2 deletions examples/middlewares/src/valibot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createServer } from "node:http"
import { query, resolver, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, query, resolver, weave } from "@gqloom/valibot"
import { createYoga } from "graphql-yoga"
import * as v from "valibot"
import { ValibotExceptionFilter, outputValidator } from "./middlewares"
Expand Down
3 changes: 1 addition & 2 deletions examples/prisma/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as fs from "fs"
import { createServer } from "node:http"
import * as path from "path"
import { query, resolver, weave } from "@gqloom/core"
import { PrismaModelBobbin } from "@gqloom/prisma"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, query, resolver, weave } from "@gqloom/valibot"
import { PrismaClient } from "@prisma/client"
import { printSchema } from "graphql"
import { createYoga } from "graphql-yoga"
Expand Down
9 changes: 7 additions & 2 deletions examples/subscriptions/src/valibot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { createServer } from "node:http"
import { query, resolver, subscription, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import {
ValibotWeaver,
query,
resolver,
subscription,
weave,
} from "@gqloom/valibot"
import { createPubSub, createYoga } from "graphql-yoga"
import * as v from "valibot"

Expand Down
3 changes: 1 addition & 2 deletions website/docs/en/guide/advanced/subscription.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ In `GQLoom`, we use the `subscription` function to define a subscription:.
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts
import { weave, resolver, subscription } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, subscription } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down
3 changes: 1 addition & 2 deletions website/docs/en/guide/fundamentals/middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ Let's try to use this middleware:
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down
6 changes: 2 additions & 4 deletions website/docs/en/guide/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ Then, we create an `src/index.ts` file and add the following code:
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts title="src/index.ts"
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down Expand Up @@ -274,8 +273,7 @@ Now, let's go back to the beginning with `CatResolver` and add a `query` operati
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts title="src/index.ts"
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"

const CatResolver = resolver({ // [!code hl]
Expand Down
3 changes: 1 addition & 2 deletions website/docs/en/guide/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ The design of GQLoom is inspired by [tRPC](https://trpc.io/), [TypeGraphQL](http
<Tabs>
<Tab label="valibot">
```ts
import { resolver, query, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"

const HelloResolver = resolver({
Expand Down
3 changes: 1 addition & 2 deletions website/docs/en/guide/schema-integration/valibot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const IntScalar = v.pipe(v.nullable(v.number()), v.integer()) // GraphQLInt
To ensure that `GQLoom` correctly weaves Valibot schemas into the GraphQL schema, we need to add the `ValibotWeaver` from `@gqloom/valibot` when using the `weave` function.

```ts
import { resolver, query ,weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"

export const helloResolver = resolver({
hello: query(v.string(), () => "Hello, World!"),
Expand Down
3 changes: 1 addition & 2 deletions website/docs/zh/guide/advanced/subscription.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { Tab, Tabs } from 'rspress/theme';
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts
import { weave, resolver, subscription } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, subscription } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down
3 changes: 1 addition & 2 deletions website/docs/zh/guide/fundamentals/middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ export const outputValidator: Middleware = async ({ next, outputSilk }) => {
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down
6 changes: 2 additions & 4 deletions website/docs/zh/guide/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ npx tsc --init
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts title="src/index.ts"
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"
import { createServer } from "node:http"
import { createYoga } from "graphql-yoga"
Expand Down Expand Up @@ -274,8 +273,7 @@ const catMap = new Map<string, ICat>([
<Tabs groupId='schema-builder'>
<Tab label="valibot">
```ts title="src/index.ts"
import { weave, resolver, query } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"
import * as v from "valibot"

const CatResolver = resolver({ // [!code hl]
Expand Down
3 changes: 1 addition & 2 deletions website/docs/zh/guide/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ GQLoom 的设计受 [tRPC](https://trpc.io/)、[TypeGraphQL](https://typegraphql
<Tabs>
<Tab label="valibot">
```ts
import { resolver, query, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, resolver, query, weave } from "@gqloom/valibot"
import * as v from "valibot"

const HelloResolver = resolver({
Expand Down
3 changes: 1 addition & 2 deletions website/docs/zh/guide/schema-integration/valibot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const IntScalar = v.pipe(v.nullable(v.number()), v.integer()) // GraphQLInt
为了让 `GQLoom` 能正确地将 Valibot Schema 编织到 GraphQL Schema,我们在使用 `weave` 函数时,需要添加来自 `@gqloom/valibot``ValibotWeaver`

```ts
import { resolver, query ,weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { ValibotWeaver, weave, resolver, query } from "@gqloom/valibot"

export const helloResolver = resolver({
hello: query(v.string(), () => "Hello, World!"),
Expand Down

0 comments on commit 7b80008

Please sign in to comment.