Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Merge packages of different integration #8

Merged
merged 21 commits into from
Apr 14, 2020
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
5 changes: 2 additions & 3 deletions .github/actions/graphql-bench-pr/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ async function prepareRepo(repo, ref, outDir) {
async function runManyBenches(dir, packages) {
// Run benchmark
let packagesArgs = packages.join(' ');
const benchCmd = `node ${dir}/bench/bench -c 100 -d 5 -p 10 --packages ${packagesArgs} --silent`
console.log(benchCmd)
const benchCmd = `node ${dir}/bench/bench -c 100 -d 10 -p 10 --packages ${packagesArgs} --silent`
await exec(benchCmd);
}

async function getStats(repo, ref) {
const dir = repo.replace('/', '-');
await prepareRepo(repo, ref, dir);
await runManyBenches(dir, ['graphyne-express', 'graphyne-server']);
await runManyBenches(dir, ['graphyne-server']);
// Get the result
const resultsPath = join(cwd, dir, 'bench', 'results');
const resultObj = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const express = require('express');
const { GraphyneServer } = require('graphyne-express');
const { GraphyneServer } = require('graphyne-server');
const { schema } = require('../buildSchema');

const graphyne = new GraphyneServer({
Expand Down
1 change: 0 additions & 1 deletion bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"express": "^4.17.1",
"express-graphql": "latest",
"faker": "^4.1.0",
"graphyne-express": ">0.0.0",
"graphyne-server": ">0.0.0",
"markdown-table": "^2.0.0",
"md5": "^2.2.1",
Expand Down
15 changes: 8 additions & 7 deletions examples/with-express/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const express = require('express');
const { GraphyneServer } = require('graphyne-express');
const { GraphyneServer } = require('graphyne-server');
const { makeExecutableSchema } = require('graphql-tools');

const typeDefs = `
Expand All @@ -20,20 +20,21 @@ var schema = makeExecutableSchema({

const graphyne = new GraphyneServer({
schema,
context: () => ({ world: 'world' }),
context: (req, res) => ({ world: 'world' }),
});

const app = express();
app.all('/graphql', graphyne.createHandler());
// Use GraphiQL
app.get(
'/___graphql',

app.use(
graphyne.createHandler({
path: '/graphql', // This must be set for graphiql to work
path: '/graphql',
graphiql: {
path: '/___graphql',
defaultQuery: 'query { hello }',
},
onNoMatch: (req, res, next) => next(),
})
);

app.listen(4000);
console.log('Running a GraphQL API server at http://localhost:4000/graphql');
2 changes: 1 addition & 1 deletion examples/with-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"express": "^4.17.1",
"graphql": "^15.0.0",
"graphql-tools": "^4.0.7",
"graphyne-express": "latest"
"graphyne-server": "^0.2.0"
},
"license": "ISC"
}
42 changes: 42 additions & 0 deletions examples/with-fastify/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fastify = require('fastify')({
logger: true,
});
const { GraphyneServer } = require('graphyne-server');
const { makeExecutableSchema } = require('graphql-tools');

const typeDefs = `
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: (obj, variables, context) => `Hello ${context.world}!`,
},
};

var schema = makeExecutableSchema({
typeDefs,
resolvers,
});

const graphyne = new GraphyneServer({
schema,
context: (req, res) => ({ world: 'world' }),
});

fastify.use(
graphyne.createHandler({
path: '/graphql',
graphiql: {
path: '/___graphql',
defaultQuery: 'query { hello }',
},
onNoMatch: (req, res, next) => next(),
})
);

fastify.listen(3000, (err, address) => {
if (err) throw err;
fastify.log.info(`server listening on ${address}`);
});
14 changes: 14 additions & 0 deletions examples/with-fastify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "with-fastify",
"private": true,
"scripts": {
"start": "node index.js"
},
"dependencies": {
"fastify": "^2.13.1",
"graphql": "^15.0.0",
"graphql-tools": "^4.0.7",
"graphyne-server": "^0.2.0"
},
"license": "ISC"
}
2 changes: 1 addition & 1 deletion examples/with-graphyne/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"graphql": "^15.0.0",
"graphql-tools": "^4.0.7",
"graphyne-server": "latest"
"graphyne-server": "^0.2.0"
},
"license": "ISC"
}
46 changes: 46 additions & 0 deletions examples/with-koa/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const Koa = require('koa');
const { GraphyneServer } = require('graphyne-server');
const { makeExecutableSchema } = require('graphql-tools');

const typeDefs = `
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: (obj, variables, context) => `Hello ${context.world}!`,
},
};

var schema = makeExecutableSchema({
typeDefs,
resolvers,
});

const graphyne = new GraphyneServer({
schema,
context: (req, res) => ({ world: 'world' }),
});

const app = new Koa();

app.use(
graphyne.createHandler({
path: '/graphql',
graphiql: {
path: '/___graphql',
defaultQuery: 'query { hello }',
},
integrationFn: (ctx, next) => {
// https://github.com/koajs/koa/blob/master/lib/context.js#L54
return {
request: ctx.req,
response: ctx.res,
};
},
})
);

app.listen(3000);
console.log('Running a GraphQL API server at http://localhost:3000/graphql');
14 changes: 14 additions & 0 deletions examples/with-koa/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "with-koa",
"private": true,
"scripts": {
"start": "node index.js"
},
"dependencies": {
"graphql": "^15.0.0",
"graphql-tools": "^4.0.7",
"graphyne-server": "^0.2.0",
"koa": "^2.11.0"
},
"license": "ISC"
}
32 changes: 32 additions & 0 deletions examples/with-micro/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { send } = require('micro');
const { GraphyneServer } = require('graphyne-server');
const { makeExecutableSchema } = require('graphql-tools');

const typeDefs = `
type Query {
hello: String
}
`;
const resolvers = {
Query: {
hello: (obj, variables, context) => `Hello ${context.world}!`,
},
};

var schema = makeExecutableSchema({
typeDefs,
resolvers,
});

const graphyne = new GraphyneServer({
schema,
context: (req, res) => ({ world: 'world' }),
});

module.exports = graphyne.createHandler({
// other options
onNoMatch: async (req, res) => {
const statusCode = 400;
send(res, statusCode, 'not found');
},
});
15 changes: 15 additions & 0 deletions examples/with-micro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "with-koa",
"private": true,
"main": "index.js",
"scripts": {
"start": "micro"
},
"dependencies": {
"graphql": "^15.0.0",
"graphql-tools": "^4.0.7",
"graphyne-server": "^0.2.0",
"micro": "^9.3.4"
},
"license": "ISC"
}
Loading