Skip to content

Commit

Permalink
feat: single package (#1471)
Browse files Browse the repository at this point in the history
* single package for yoga

* docs: v3 wip documentation

* fix: use correct layout component
  • Loading branch information
n1ru4l authored and ardatan committed Jul 27, 2022
1 parent 36b69dd commit f46addd
Show file tree
Hide file tree
Showing 188 changed files with 8,494 additions and 1,159 deletions.
8 changes: 8 additions & 0 deletions .changeset/chilly-windows-happen.md
@@ -0,0 +1,8 @@
---
'graphql-yoga': major
'@graphql-yoga/common': major
'@graphql-yoga/node': major
---

See the migration guide for more information;
[Migration from Yoga V2](https://www.graphql-yoga.com/docs/migration/migration-from-yoga-v2)
1 change: 1 addition & 0 deletions .github/workflows/deployment-e2e.yml
Expand Up @@ -9,6 +9,7 @@ jobs:
strategy:
matrix:
plan: ['cf-worker', 'azure-function', 'aws-lambda', 'vercel-function']
fail-fast: false
name: ${{ matrix.plan }}
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
Expand Down
10 changes: 6 additions & 4 deletions README.md
Expand Up @@ -9,17 +9,18 @@ Fully-featured GraphQL Server with focus on easy setup, performance & great deve
### Installation

```shell
npm i @graphql-yoga/node graphql
npm i graphql-yoga graphql
```

### Quickstart

You will need to provide schema to Yoga, either by an existing executable schema, or by providing your type definitions and resolver map:

```ts
import { createServer } from '@graphql-yoga/node'
import { createServer } from 'http'
import { createYoga } from 'graphql-yoga'

const server = createServer({
const yoga = createYoga({
schema: {
typeDefs: /* GraphQL */ `
type Query {
Expand All @@ -34,7 +35,8 @@ const server = createServer({
},
})

server.start()
const server = createServer(yoga)
server.listen(4000)
```

## Overview
Expand Down
2 changes: 1 addition & 1 deletion benchmark/hello-world/package.json
Expand Up @@ -8,7 +8,7 @@
"check": "exit 0"
},
"dependencies": {
"@graphql-yoga/node": "2.13.4",
"graphql-yoga": "2.13.4",
"graphql": "16.5.0"
}
}
10 changes: 6 additions & 4 deletions benchmark/hello-world/start-server.js
@@ -1,9 +1,11 @@
const { createServer } = require('@graphql-yoga/node')
const { createServer } = require('http')
const { createYoga } = require('graphql-yoga')

const server = createServer({
const yoga = createYoga({
logging: false,
hostname: '127.0.0.1',
multipart: false,
})

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

server.listen(4000, '127.0.0.1')
6 changes: 3 additions & 3 deletions e2e/tests/aws-lambda.ts
Expand Up @@ -16,8 +16,8 @@ export const awsLambdaDeployment: DeploymentConfiguration<{

// Build and bundle the worker
console.info('\t\tℹ️ Bundling the AWS Lambda Function....')
await execPromise('yarn build', {
cwd: '../examples/aws-lambda-bundle',
await execPromise('yarn bundle', {
cwd: '../examples/aws-lambda',
})
},
config: async (stack: Stack) => {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const awsLambdaDeployment: DeploymentConfiguration<{
handler: 'index.handler',
code: new pulumi.asset.AssetArchive({
'index.js': new pulumi.asset.FileAsset(
'../examples/aws-lambda-bundle/dist/index.js',
'../examples/aws-lambda/dist/index.js',
),
}),
},
Expand Down
6 changes: 3 additions & 3 deletions e2e/tests/vercel.ts
Expand Up @@ -132,8 +132,8 @@ export const vercelDeployment: DeploymentConfiguration<{
prerequisites: async () => {
// Build and bundle the function
console.info('\t\tℹ️ Bundling the Vercel Function....')
await execPromise('yarn build', {
cwd: '../examples/vercel-function',
await execPromise('yarn bundle', {
cwd: '../examples/nextjs',
})
},
program: async () => {
Expand All @@ -142,7 +142,7 @@ export const vercelDeployment: DeploymentConfiguration<{
{
file: '/api/graphql.js',
data: await fsPromises.readFile(
'../examples/vercel-function/dist/index.js',
'../examples/nextjs/dist/index.js',
'utf-8',
),
},
Expand Down
8 changes: 5 additions & 3 deletions examples/apollo-federation/gateway/index.js
@@ -1,4 +1,5 @@
const { createServer } = require('@graphql-yoga/node')
const { createServer } = require('http')
const { createYoga } = require('graphql-yoga')
const { ApolloGateway } = require('@apollo/gateway')
const { useApolloFederation } = require('@envelop/apollo-federation')

Expand All @@ -14,7 +15,7 @@ async function main() {
// Make sure all services are loaded
await gateway.load()

const server = createServer({
const yoga = createYoga({
plugins: [
useApolloFederation({
gateway,
Expand All @@ -23,7 +24,8 @@ async function main() {
})

// Start the server and explore http://localhost:4000/graphql
await server.start()
const server = createServer(yoga)
server.listen(4000)
}

main().catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/apollo-federation/gateway/package.json
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@apollo/gateway": "^0.51.0",
"@envelop/apollo-federation": "^2.4.0",
"@graphql-yoga/node": "2.13.4",
"graphql-yoga": "2.13.4",
"graphql": "^16.5.0"
}
}
9 changes: 5 additions & 4 deletions examples/apollo-federation/service/index.js
@@ -1,6 +1,7 @@
const { parse } = require('graphql')
const { buildSubgraphSchema } = require('@apollo/subgraph')
const { createServer } = require('@graphql-yoga/node')
const { createServer } = require('http')
const { createYoga } = require('graphql-yoga')

const typeDefs = parse(/* GraphQL */ `
type Query {
Expand All @@ -25,11 +26,11 @@ const resolvers = {
},
},
}
const server = createServer({
const yoga = createYoga({
schema: buildSubgraphSchema([{ typeDefs, resolvers }]),
port: 4001,
})

server.start().then(() => {
const server = createServer(yoga)
server.listen(4001, () => {
console.log(`🚀 Server ready at http://localhost:4001`)
})
2 changes: 1 addition & 1 deletion examples/apollo-federation/service/package.json
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@apollo/subgraph": "^0.4.0",
"@graphql-yoga/node": "2.13.4",
"graphql-yoga": "2.13.4",
"graphql": "^16.2.0"
}
}
43 changes: 0 additions & 43 deletions examples/aws-lambda-bundle/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions examples/aws-lambda-bundle/README.md

This file was deleted.

14 changes: 0 additions & 14 deletions examples/aws-lambda-bundle/package.json

This file was deleted.

9 changes: 0 additions & 9 deletions examples/aws-lambda-bundle/src/index.ts

This file was deleted.

1 change: 1 addition & 0 deletions examples/aws-lambda/.gitignore
@@ -1,4 +1,5 @@
*.js
!scripts/*.js
!jest.config.js
*.d.ts
node_modules
Expand Down
4 changes: 2 additions & 2 deletions examples/aws-lambda/lambda/graphql.ts
@@ -1,8 +1,8 @@
import type { Handler } from '@aws-cdk/aws-lambda'
import { createServer } from '@graphql-yoga/node'
import { createYoga } from 'graphql-yoga'
import { configure } from '@vendia/serverless-express'

const app = createServer()
const app = createYoga()

export const handler: Handler = configure({
app,
Expand Down
2 changes: 2 additions & 0 deletions examples/aws-lambda/package.json
Expand Up @@ -7,6 +7,7 @@
},
"scripts": {
"build": "tsc",
"bundle": "node scripts/bundle.js",
"watch": "tsc -w",
"check": "tsc --noEmit",
"test": "jest",
Expand All @@ -21,6 +22,7 @@
"ts-node": "10.9.1",
"aws-cdk": "2.33.0",
"aws-cdk-lib": "2.33.0",
"esbuild": "0.14.49",
"typescript": "4.7.4"
},
"dependencies": {
Expand Down
Expand Up @@ -2,7 +2,7 @@ const { build } = require('esbuild')

async function main() {
await build({
entryPoints: ['./src/index.ts'],
entryPoints: ['./lambda/graphql.ts'],
outfile: 'dist/index.js',
format: 'cjs',
minify: false,
Expand Down
3 changes: 2 additions & 1 deletion examples/aws-lambda/tsconfig.json
Expand Up @@ -17,7 +17,8 @@
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"skipLibCheck": true
"skipLibCheck": true,
"importHelpers": true
},
"exclude": ["cdk.out"]
}
6 changes: 3 additions & 3 deletions examples/azure-function/src/index.ts
@@ -1,12 +1,12 @@
import { AzureFunction, Context, HttpRequest } from '@azure/functions'
import { createServer } from '@graphql-yoga/common'
import { createYoga } from 'graphql-yoga'
import { Request } from '@whatwg-node/fetch'

const httpTrigger: AzureFunction = async function (
context: Context,
req: HttpRequest,
): Promise<void> {
const app = createServer({
const app = createYoga({
logging: {
debug: context.log.verbose,
error: context.log.error,
Expand All @@ -21,7 +21,7 @@ const httpTrigger: AzureFunction = async function (

try {
const request = new Request(req.url, {
method: req.method,
method: req.method?.toString(),
body: req.rawBody,
headers: req.headers,
})
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-advanced/package.json
Expand Up @@ -7,7 +7,7 @@
"check": "tsc --pretty --noEmit"
},
"dependencies": {
"@graphql-yoga/common": "2.12.3",
"graphql-yoga": "2.13.4",
"@cloudflare/workers-types": "^3.0.0",
"graphql": "16.5.0"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/cloudflare-advanced/src/index.ts
@@ -1,8 +1,8 @@
import { createServer } from '@graphql-yoga/common'
import { createYoga } from 'graphql-yoga'

declare const EXAMPLE_KV: KVNamespace

const server = createServer({
const yoga = createYoga({
schema: {
typeDefs: /* GraphQL */ `
scalar File
Expand Down Expand Up @@ -102,4 +102,4 @@ const server = createServer({
},
})

server.start()
self.addEventListener('fetch', yoga)
2 changes: 1 addition & 1 deletion examples/cloudflare-advanced/tsconfig.json
Expand Up @@ -3,7 +3,7 @@
"outDir": "./dist",
"module": "esnext",
"target": "esnext",
"lib": ["esnext", "webworker"],
"lib": ["esnext"],
"moduleResolution": "node",
"sourceMap": true,
"skipLibCheck": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/cloudflare-modules/package.json
Expand Up @@ -10,7 +10,7 @@
"check": "tsc --pretty --noEmit"
},
"dependencies": {
"@graphql-yoga/common": "2.12.3",
"graphql-yoga": "2.13.4",
"graphql": "16.5.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions examples/cloudflare-modules/src/index.ts
@@ -1,4 +1,4 @@
// src/index.mjs
import { createServer } from '@graphql-yoga/common'
import { createYoga } from 'graphql-yoga'

export default createServer()
export default createYoga()

0 comments on commit f46addd

Please sign in to comment.