Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
examples: add graphqlYoga
Browse files Browse the repository at this point in the history
  • Loading branch information
productdevbook committed Dec 19, 2023
1 parent 4109726 commit cb86a78
Show file tree
Hide file tree
Showing 20 changed files with 2,648 additions and 152 deletions.
2 changes: 1 addition & 1 deletion examples/p-S3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@pergel/module-s3": "0.0.0",
"@pergel/nuxt": "^0.3.0"
"@pergel/nuxt": "^0.3.1"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
2 changes: 1 addition & 1 deletion examples/p-S3/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
S3:
env:
Expand Down
2 changes: 1 addition & 1 deletion examples/p-bullmq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@pergel/nuxt": "^0.3.0",
"@pergel/nuxt": "^0.3.1",
"bullmq": "^4.15.3",
"ioredis": "^5.3.2",
"p-timeout": "^6.1.2"
Expand Down
2 changes: 1 addition & 1 deletion examples/p-bullmq/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
bullmq:
env:
Expand Down
5 changes: 4 additions & 1 deletion examples/p-graphqlYoga/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// https://nuxt.com/docs/api/configuration/nuxt-config

export default defineNuxtConfig({
devtools: { enabled: true },
modules: [
Expand All @@ -7,7 +8,9 @@ export default defineNuxtConfig({
pergel: {
projects: {
rocket: {
graphqlYoga: true,
graphqlYoga: {
mergeSchemas: true,
},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion examples/p-graphqlYoga/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@pergel/nuxt": "^0.3.0"
"@pergel/graphql": "0.0.0",
"@pergel/nuxt": "^0.3.1"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
8 changes: 4 additions & 4 deletions examples/p-graphqlYoga/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
nodeCron:
graphqlYoga:
# If pergel cli is installed, you can run `pergel install` automatically to install
packageJson:
dependencies: "node-cron@^3.0.3"
devDependencies: "@types/node-cron@^3.0.11"
dependencies: "@pergel/graphql@0.0.0"
devDependencies: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query book {
book(id: 1) {
id
name
}
}

13 changes: 13 additions & 0 deletions examples/p-graphqlYoga/pergel/rocket/graphqlYoga/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module 'pergel/rocket/types' {

import type { IncomingMessage, ServerResponse } from 'node:http'
import type { H3Event } from 'h3'
import type { YogaInitialContext } from 'graphql-yoga'

interface GraphqlYogaContext extends YogaInitialContext {
res: ServerResponse
req: IncomingMessage
event: H3Event
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type Query {
book(id: ID!): Book!
books: [Book!]!
}

type Book {
id: ID!
name: String!
email: String!
password: String!
createdAt: String!
updatedAt: String
}

13 changes: 13 additions & 0 deletions examples/p-graphqlYoga/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type Query {
book(id: ID!): Book!
books: [Book!]!
}

type Book {
id: ID!
name: String!
email: String!
password: String!
createdAt: String!
updatedAt: String
}
35 changes: 35 additions & 0 deletions examples/p-graphqlYoga/server/plugins/graphqlv1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { createSchema } from 'graphql-yoga'
import type { Resolvers } from 'pergel/rocket/graphqlYoga/server'
import { schema } from 'pergel/rocket/graphqlYoga/schema'

const resolvers: Resolvers = {
Query: {
book: (_root, _args, _context, _info) => {
return {
id: '1',
name: 'hello',
email: 'hello',
createdAt: 'hello',
password: 'hello',
}
},
},
}
const schemas = createSchema({
typeDefs: schema,
resolvers,
})

export default pergelRocket().graphqlYoga().nitro().use({
onBeforeOptions: async ({ options }) => {
options.add({
schema: schemas,
})
},
async onBeforeContext({ options }) {
const data = await options.add({

})
console.warn(data)
},
})
19 changes: 0 additions & 19 deletions examples/p-graphqlYoga/server/plugins/hello.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/p-json2csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@json2csv/node": "^7.0.4",
"@pergel/nuxt": "^0.3.0",
"@pergel/nuxt": "^0.3.1",
"node-cron": "^3.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/p-json2csv/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
json2csv:
# If pergel cli is installed, you can run `pergel install` automatically to install
Expand Down
2 changes: 1 addition & 1 deletion examples/p-nodeCron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "nuxt prepare"
},
"dependencies": {
"@pergel/nuxt": "^0.3.0",
"@pergel/nuxt": "^0.3.1",
"node-cron": "^3.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/p-nodeCron/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
nodeCron:
# If pergel cli is installed, you can run `pergel install` automatically to install
Expand Down
2 changes: 1 addition & 1 deletion examples/p-ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@aws-sdk/client-ses": "^3.470.0",
"@pergel/nuxt": "^0.3.0"
"@pergel/nuxt": "^0.3.1"
},
"devDependencies": {
"@nuxt/devtools": "latest",
Expand Down
2 changes: 1 addition & 1 deletion examples/p-ses/pergel/README.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pergel:
# This file is generated by pergel. Do not edit it manually.
# Version: 0.3.0
# Version: 0.3.1
rocket:
ses:
env:
Expand Down
Loading

0 comments on commit cb86a78

Please sign in to comment.