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

docs: update example for yoga v3 #670

Merged
merged 4 commits into from
Nov 24, 2022
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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ methods that can take full advantage of the Pothos type system.
## Hello, World

```typescript
import { createServer } from '@graphql-yoga/node';
import { createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';
import SchemaBuilder from '@pothos/core';

const builder = new SchemaBuilder({});
Expand All @@ -34,11 +35,13 @@ builder.queryType({
}),
});

const server = createServer({
const yoga = createYoga({
schema: builder.toSchema(),
});

server.start();
const server = createServer(yoga);

server.listen(3000);
```

## What sets Pothos apart
Expand Down
6 changes: 3 additions & 3 deletions examples/complex-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "^2.13.13",
"@pothos/core": "^3.23.0",
"@pothos/plugin-dataloader": "workspace:*",
"@pothos/plugin-prisma": "workspace:*",
Expand All @@ -27,8 +26,9 @@
"@pothos/plugin-validation": "workspace:*",
"@prisma/client": "^4.5.0",
"graphql": "16.6.0",
"graphql-scalars": "^1.20.0",
"prisma": "^4.5.0"
"graphql-scalars": "^1.20.1",
"graphql-yoga": "3.0.3",
"prisma": "^4.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 7 additions & 5 deletions examples/complex-app/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

const server = createServer({
const yoga = createYoga({
schema,
});

server.start().catch((error) => {
console.error(error);
});
const server = createServer(yoga);

const port = 3000;
server.listen(port);
4 changes: 2 additions & 2 deletions examples/envelope-helix-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"type": "tsc --noEmit"
},
"dependencies": {
"@envelop/core": "^3.0.3",
"@envelop/core": "^3.0.4",
"@faker-js/faker": "^7.6.0",
"@pothos/core": "workspace:*",
"fastify": "^4.9.2",
"fastify": "^4.10.2",
"graphql": "16.6.0",
"graphql-helix": "^1.13.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/graphql-shield/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example shows how you can create a simple plugin to apply graphql shield ru
This example uses the following packages:

- `@pothos/core`: For building the schema
- `@graphql-yoga/node`: For creating a server that executes the schema
- `graphql-yoga`: For creating a server that executes the schema

## Schema

Expand Down
4 changes: 2 additions & 2 deletions examples/graphql-shield/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "2.13.13",
"@pothos/core": "workspace:*",
"graphql": "16.6.0",
"graphql-middleware": "^6.1.33",
"graphql-shield": "^7.6.3"
"graphql-shield": "^7.6.5",
"graphql-yoga": "3.0.3"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion examples/graphql-shield/src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { YogaInitialContext } from '@graphql-yoga/node';
import { YogaInitialContext } from 'graphql-yoga';
import SchemaBuilder from '@pothos/core';
import Plugin from './shield-plugin';

Expand Down
13 changes: 8 additions & 5 deletions examples/graphql-shield/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

export const server = createServer({
const yoga = createYoga({
schema,
context: (ctx) => ({
user: { id: Number.parseInt(ctx.request.headers.get('x-user-id') ?? '1', 10) },
}),
});

server.start().catch((error) => {
console.error(error);
});
export const server = createServer(yoga);

const port = 3000;

server.listen(port);
16 changes: 8 additions & 8 deletions examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@apollo/client": "^3.7.1",
"@faker-js/faker": "^7.6.0",
"@pothos/core": "workspace:*",
"@tanstack/react-query": "^4.13.0",
"@tanstack/react-query": "^4.16.1",
"graphql": "16.6.0",
"graphql-helix": "^1.13.0",
"graphql-tag": "^2.12.6",
Expand All @@ -22,17 +22,17 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@graphql-codegen/cli": "^2.13.8",
"@graphql-codegen/near-operation-file-preset": "^2.4.3",
"@graphql-codegen/cli": "^2.13.12",
"@graphql-codegen/near-operation-file-preset": "^2.4.4",
"@graphql-codegen/schema-ast": "^2.5.1",
"@graphql-codegen/typescript": "^2.8.0",
"@graphql-codegen/typescript-operations": "^2.5.5",
"@graphql-codegen/typescript-react-apollo": "^3.3.5",
"@graphql-codegen/typescript": "^2.8.2",
"@graphql-codegen/typescript-operations": "^2.5.7",
"@graphql-codegen/typescript-react-apollo": "^3.3.7",
"@types/node": "18.11.7",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"concurrently": "^7.5.0",
"typescript": "^4.8.4"
"concurrently": "^7.6.0",
"typescript": "^4.9.3"
},
"engines": {
"node": ">=12.0.0"
Expand Down
10 changes: 5 additions & 5 deletions examples/open-telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@graphql-yoga/node": "^2.13.13",
"@opentelemetry/api": "^1.2.0",
"@opentelemetry/exporter-zipkin": "^1.7.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/exporter-zipkin": "^1.8.0",
"@opentelemetry/instrumentation": "^0.33.0",
"@opentelemetry/instrumentation-http": "^0.33.0",
"@opentelemetry/sdk-trace-base": "^1.7.0",
"@opentelemetry/sdk-trace-node": "^1.7.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@opentelemetry/sdk-trace-node": "^1.8.0",
"@pothos/core": "workspace:*",
"@pothos/plugin-tracing": "workspace:*",
"@pothos/tracing-opentelemetry": "workspace:*",
"bema": "^0.1.2",
"graphql": "16.6.0",
"graphql-yoga": "3.0.3",
"tsm": "^2.2.2"
},
"publishConfig": {
Expand Down
11 changes: 8 additions & 3 deletions examples/open-telemetry/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createServer } from '@graphql-yoga/node';
import { createYoga } from 'graphql-yoga';
import { createServer } from 'node:http';
import { AttributeValue } from '@opentelemetry/api';
import SchemaBuilder from '@pothos/core';
import TracingPlugin, { isRootField } from '@pothos/plugin-tracing';
Expand Down Expand Up @@ -27,9 +28,13 @@ export const builder = new SchemaBuilder<{
},
});

const server = createServer({
const yoga = createYoga({
schema,
plugins: [tracingPlugin],
});

server.start().catch(console.error);
const server = createServer(yoga);

const port = 3000;

server.listen(port);
6 changes: 3 additions & 3 deletions examples/prisma-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
},
"dependencies": {
"@apollo/gateway": "2.1.4",
"@apollo/server": "^4.0.4",
"@apollo/server": "^4.2.1",
"@apollo/subgraph": "2.1.4",
"@faker-js/faker": "^7.6.0",
"@pothos/core": "workspace:*",
"@pothos/plugin-directives": "workspace:*",
"@pothos/plugin-federation": "workspace:*",
"@pothos/plugin-prisma": "workspace:*",
"@prisma/client": "^4.5.0",
"@prisma/client": "^4.6.1",
"graphql": "16.6.0",
"prisma": "^4.5.0"
"prisma": "^4.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-relay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This example uses the following packages:
- `@pothos/plugin-relay`: For adding relay compatible connections and nodes
- `@prisma/client`: For querying data from a database
- `prisma`: For running migrations and generating `@prisma/client`
- `@graphql-yoga/node`: For creating a server that executes the schema
- `graphql-yoga`: For creating a server that executes the schema

## Schema

Expand Down
6 changes: 3 additions & 3 deletions examples/prisma-relay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "^2.13.13",
"@pothos/core": "^3.23.0",
"@pothos/plugin-prisma": "workspace:*",
"@pothos/plugin-relay": "workspace:*",
"@prisma/client": "^4.5.0",
"@prisma/client": "^4.6.1",
"graphql": "16.6.0",
"prisma": "^4.5.0"
"graphql-yoga": "3.0.3",
"prisma": "^4.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 8 additions & 5 deletions examples/prisma-relay/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

const server = createServer({
const yoga = createYoga({
schema,
});

server.start().catch((error) => {
console.error(error);
});
const server = createServer(yoga);

const port = 3000;

server.listen(port);
2 changes: 1 addition & 1 deletion examples/prisma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This example uses the following packages:
- `@pothos/plugin-prisma`: For prisma based type definitions, and efficient queries
- `@prisma/client`: For querying data from a database
- `prisma`: For running migrations and generating `@prisma/client`
- `@graphql-yoga/node`: For creating a server that executes the schema
- `graphql-yoga`: For creating a server that executes the schema

## Schema

Expand Down
6 changes: 3 additions & 3 deletions examples/prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "^2.13.13",
"@pothos/core": "workspace:*",
"@pothos/plugin-prisma": "workspace:*",
"@prisma/client": "^4.5.0",
"@prisma/client": "^4.6.1",
"graphql": "16.6.0",
"prisma": "^4.5.0"
"graphql-yoga": "3.0.3",
"prisma": "^4.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 8 additions & 5 deletions examples/prisma/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

const server = createServer({
const yoga = createYoga({
schema,
});

server.start().catch((error) => {
console.error(error);
});
const server = createServer(yoga);

const port = 3000;

server.listen(port);
4 changes: 2 additions & 2 deletions examples/relay-windowed-pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "2.13.13",
"@pothos/core": "workspace:*",
"@pothos/plugin-relay": "workspace:*",
"graphql": "16.6.0",
"prisma": "^4.5.0"
"graphql-yoga": "3.0.3",
"prisma": "^4.6.1"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 8 additions & 5 deletions examples/relay-windowed-pagination/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

const server = createServer({
const yoga = createYoga({
schema,
});

server.start().catch((error) => {
console.error(error);
});
const server = createServer(yoga);

const port = 3000;

server.listen(port);
2 changes: 1 addition & 1 deletion examples/simple-classes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example shows how to create a GraphQL API that exposes data defined by clas
This example uses the following packages:

- `@pothos/core`: For building the schema
- `@graphql-yoga/node`: For creating a server that executes the schema
- `graphql-yoga`: For creating a server that executes the schema

## Schema

Expand Down
4 changes: 2 additions & 2 deletions examples/simple-classes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
},
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@graphql-yoga/node": "^2.13.13",
"@pothos/core": "workspace:*",
"graphql": "16.6.0"
"graphql": "16.6.0",
"graphql-yoga": "3.0.3"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 7 additions & 5 deletions examples/simple-classes/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { createServer } from '@graphql-yoga/node';
import { createServer } from 'node:http';
import { createYoga } from 'graphql-yoga';
import { schema } from './schema';

const server = createServer({
const yoga = createYoga({
schema,
});

server.start().catch((error) => {
console.error(error);
});
const server = createServer(yoga);

const port = 3000;
server.listen(port);
2 changes: 1 addition & 1 deletion examples/simple-interfaces/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example shows how to create a GraphQL API that exposes data that is describ
This example uses the following packages:

- `@pothos/core`: For building the schema
- `@graphql-yoga/node`: For creating a server that executes the schema
- `graphql-yoga`: For creating a server that executes the schema

## Schema

Expand Down
Loading