Skip to content
Open
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
16 changes: 16 additions & 0 deletions mock/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const express = require('express');
const bodyParser = require('body-parser');
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express');
const { addMockFunctionsToSchema, makeExecutableSchema } = require('graphql-tools');

const typeDefs = require('./type_defs');
const schema = makeExecutableSchema({ typeDefs });
const mocks = require('./mocks')
addMockFunctionsToSchema({ schema, mocks });

const app = express();
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
app.use("/graphiql", graphiqlExpress({ endpointURL: "/graphql" }));
app.listen(3000, () => {
console.log('/graphiql is running');
});
8 changes: 8 additions & 0 deletions mock/mocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
Author: () => ({
name: 'Takayuki Matsubara',
}),
Book: () => ({
name: 'Elixir Book',
}),
};
Loading