Skip to content

Commit

Permalink
express and yoga
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Jul 16, 2024
1 parent 987afce commit 3fd9512
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ applyMiddleware(
{ Query: { beers: true } },
);

graphqlYogaAdapter(resolvers).listen(4000, () => {
graphqlYogaAdapter(resolvers).server.listen(4000, () => {
console.log('LISTENING');
});
```
Expand Down
4 changes: 2 additions & 2 deletions adapters/apollo-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions adapters/apollo-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-apollo-server",
"version": "0.3.3",
"version": "0.3.4",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand All @@ -14,7 +14,7 @@
"lib"
],
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"@apollo/server": "^4.9.4",
"@graphql-tools/schema": "^9.0.19",
"@graphql-tools/utils": "^9.2.1"
Expand Down
2 changes: 1 addition & 1 deletion adapters/graphql-yoga/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ export const graphqlYogaAdapter = AxolotlAdapter<[any, any, YogaInitialContext],
});

const server = createServer(yoga);
return server;
return { server, yoga };
});
4 changes: 2 additions & 2 deletions adapters/graphql-yoga/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-graphql-yoga",
"version": "0.3.3",
"version": "0.3.4",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand All @@ -14,7 +14,7 @@
"lib"
],
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"@graphql-tools/utils": "^10.3.2",
"graphql-yoga": "^4.0.5"
},
Expand Down
4 changes: 2 additions & 2 deletions adapters/stucco/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-stucco",
"version": "0.3.3",
"version": "0.3.4",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand All @@ -14,7 +14,7 @@
"lib"
],
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"stucco-js": "^0.10.19"
}
}
26 changes: 25 additions & 1 deletion docs/pages/adapters/graphql-yoga.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,32 @@ Then write your `index.ts` file.
import { adapter } from './axolotl.js';
import resolvers from './resolvers.js';

adapter(resolvers).listen(4000, () => {
adapter(resolvers).server.listen(4000, () => {
console.log('LISTENING');
});
```

You can also use this adapter with express. This is useful when dealing with
webhooks. Take a look how to implement a simple webhook.

```ts filename="index.ts"
import { adapter } from './axolotl.js';
import resolvers from './resolvers.js';
import express from 'express'

const app = express();

const {yoga} = adapter(resolvers);

app.use(yoga.graphqlEndpoint, yoga)

app.get('/webhook', (req, res) => {
res.send('Show me the money!')
})

app.listen(4000, () => {
console.log('Running a GraphQL API server at http://localhost:4000/graphql')
})
```

And you can implement anything you want in express now.
2 changes: 1 addition & 1 deletion docs/pages/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ applyMiddleware(
{ Query: { beers: true } },
);

graphqlYogaAdapter(resolvers).listen(4000, () => {
graphqlYogaAdapter(resolvers).server.listen(4000, () => {
console.log('LISTENING');
});
```
Expand Down
8 changes: 4 additions & 4 deletions examples/beerpub-apollo-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub-apollo-server",
"version": "0.3.3",
"version": "0.3.4",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"type": "module",
Expand All @@ -17,15 +17,15 @@
"author": "GraphQL Editor Centaur Generator",
"license": "ISC",
"dependencies": {
"@aexol/axolotl-apollo-server": "^0.3.3",
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-apollo-server": "^0.3.4",
"@aexol/axolotl-core": "^0.3.4",
"@apollo/server": "^4.9.4",
"graphql": "^16.8.1",
"node-fetch": "^3.2.10",
"ws": "^8.12.0"
},
"devDependencies": {
"@aexol/axolotl": "^0.3.3",
"@aexol/axolotl": "^0.3.4",
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/beerpub-yoga/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub-yoga",
"version": "0.4.3",
"version": "0.4.4",
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
"type": "module",
Expand All @@ -20,15 +20,15 @@
"author": "GraphQL Editor Centaur Generator",
"license": "ISC",
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-graphql-yoga": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"@aexol/axolotl-graphql-yoga": "^0.3.4",
"graphql": "^16.8.1",
"graphql-yoga": "^4.0.5",
"node-fetch": "^3.2.10",
"ws": "^8.12.0"
},
"devDependencies": {
"@aexol/axolotl": "^0.3.3",
"@aexol/axolotl": "^0.3.4",
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/beerpub-yoga/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ applyMiddleware(
{ Query: { beers: true } },
);

adapter({ resolvers, directives }).listen(parseInt(process.env.PORT || '4000'), () => {
adapter({ resolvers, directives }).server.listen(parseInt(process.env.PORT || '4000'), () => {
console.log('LISTENING to ' + process.env.PORT || '4000');
});
8 changes: 4 additions & 4 deletions examples/beerpub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beerpub",
"version": "0.3.3",
"version": "0.3.4",
"private": true,
"description": "Automatically generated by graphql-editor-cli",
"main": "lib/index.js",
Expand All @@ -17,14 +17,14 @@
"author": "GraphQL Editor Centaur Generator",
"license": "ISC",
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-stucco": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"@aexol/axolotl-stucco": "^0.3.4",
"node-fetch": "^3.2.10",
"stucco-js": "^0.10.19",
"ws": "^8.12.0"
},
"devDependencies": {
"@aexol/axolotl": "^0.3.3",
"@aexol/axolotl": "^0.3.4",
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl",
"version": "0.3.3",
"version": "0.3.4",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand All @@ -17,7 +17,7 @@
"lib"
],
"dependencies": {
"@aexol/axolotl-core": "^0.3.3",
"@aexol/axolotl-core": "^0.3.4",
"chalk": "^5.3.0",
"chokidar": "^3.6.0",
"commander": "^11.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aexol/axolotl-core",
"version": "0.3.3",
"version": "0.3.4",
"private": false,
"main": "./lib/index.js",
"author": "Aexol, Artur Czemiel",
Expand Down

0 comments on commit 3fd9512

Please sign in to comment.