added graphql provider test
This commit is contained in:
36
pact/pact-node-provider/routes/graphql.js
Normal file
36
pact/pact-node-provider/routes/graphql.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const graphqlHTTP = require('express-graphql');
|
||||
const {buildSchema} = require("graphql");
|
||||
|
||||
const heroesSchema = buildSchema(`
|
||||
type Query {
|
||||
hero(id: Int!): Hero
|
||||
}
|
||||
|
||||
type Hero {
|
||||
id: Int!
|
||||
name: String!
|
||||
superpower: String!
|
||||
universe: String!
|
||||
}
|
||||
`);
|
||||
|
||||
const getHero = function () {
|
||||
return {
|
||||
id: 42,
|
||||
name: "Superman",
|
||||
superpower: "Flying",
|
||||
universe: "DC"
|
||||
}
|
||||
};
|
||||
|
||||
const root = {
|
||||
hero: getHero
|
||||
};
|
||||
|
||||
const router = graphqlHTTP({
|
||||
schema: heroesSchema,
|
||||
graphiql: true,
|
||||
rootValue: root
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user