Skip to content

Commit

Permalink
more fixxxesss
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l committed Jul 29, 2022
1 parent e28277c commit ba74477
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 8 deletions.
19 changes: 18 additions & 1 deletion examples/aws-lambda/lambda/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import type { Handler } from '@aws-cdk/aws-lambda'
import { createYoga } from 'graphql-yoga'
import { createSchema } from 'graphql-yoga/schema'
import { configure } from '@vendia/serverless-express'

const app = createYoga()
const app = createYoga({
graphqlEndpoint: '/graphql',
landingPage: false,
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () =>
'This is the `greetings` field of the root `Query` type',
},
},
}),
})

export const handler: Handler = configure({
app,
Expand Down
14 changes: 14 additions & 0 deletions examples/azure-function/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AzureFunction, Context, HttpRequest } from '@azure/functions'
import { createYoga } from 'graphql-yoga'
import { createSchema } from 'graphql-yoga/schema'
import { Request } from '@whatwg-node/fetch'

const httpTrigger: AzureFunction = async function (
Expand All @@ -14,6 +15,19 @@ const httpTrigger: AzureFunction = async function (
warn: context.log.warn,
},
graphqlEndpoint: '/api/yoga',
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () =>
'This is the `greetings` field of the root `Query` type',
},
},
}),
})
context.log('HTTP trigger function processed a request.')

Expand Down
5 changes: 3 additions & 2 deletions examples/cloudflare-advanced/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createYoga } from 'graphql-yoga'
import { createSchema } from 'graphql-yoga/schema'

declare const EXAMPLE_KV: KVNamespace

const yoga = createYoga({
schema: {
schema: createSchema({
typeDefs: /* GraphQL */ `
scalar File
scalar JSON
Expand Down Expand Up @@ -99,7 +100,7 @@ const yoga = createYoga({
},
},
},
},
}),
})

self.addEventListener('fetch', yoga)
19 changes: 18 additions & 1 deletion examples/cloudflare-modules/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
// src/index.mjs
import { createYoga } from 'graphql-yoga'
import { createSchema } from 'graphql-yoga/schema'

export default createYoga()
export default createYoga({
graphqlEndpoint: '/graphql',
landingPage: false,
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () =>
'This is the `greetings` field of the root `Query` type',
},
},
}),
})
13 changes: 13 additions & 0 deletions examples/nextjs/pages/api/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { createYoga } from 'graphql-yoga'
import { createSchema } from 'graphql-yoga/schema'
import type { NextApiRequest, NextApiResponse } from 'next'

// Docs: https://vercel.com/docs/concepts/functions/serverless-functions
Expand All @@ -16,4 +17,16 @@ export default createYoga<{
res: NextApiResponse
}>({
graphqlEndpoint: '/api/graphql',
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () => 'Hello world!',
},
},
}),
})
4 changes: 2 additions & 2 deletions examples/node-esm/__tests__/esm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import supertest from 'supertest'
import { yoga } from '../yoga.mjs'

describe('Node ESM', () => {
it('should work', () => {
supertest(yoga)
it('should work', async () => {
await supertest(yoga)
.post('/graphql')
.send({
query: '{ greetings }',
Expand Down
4 changes: 2 additions & 2 deletions examples/node-esm/yoga.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export const yoga = createYoga({
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
hello: String
greetings: String
}
`,
resolvers: {
Query: {
hello: () => 'Hello world!',
greetings: () => 'Hello world!',
},
},
}),
Expand Down

0 comments on commit ba74477

Please sign in to comment.