Skip to content

Commit

Permalink
feat(hapi): add ability to specify a config parameter for the GraphQL…
Browse files Browse the repository at this point in the history
… route
  • Loading branch information
developer-rakeshpaul authored and András Tóth committed Sep 19, 2016
1 parent 6c92d70 commit f07a7a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ server.register({
register: graffiti.hapi,
options: {
schema: getSchema([User, Cat]),
context: {} // custom context
context: {}, // custom context
config: {} // config parameter for hapi graphql route
}
}, function (err) {
if (err) {
Expand Down
4 changes: 3 additions & 1 deletion src/hapi/hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function accepts({ headers }, type) {
}

const plugin = {
register: (server, { graphiql = true, context = {}, schema = required() } = {}, next) => {
register: (server, { graphiql = true, context = {}, config = {}, schema = required() } = {}, next) => {
const handler = (request, reply) => {
const data = request.payload || request.query || {};
const { query, variables } = data;
Expand Down Expand Up @@ -54,13 +54,15 @@ const plugin = {
server.route({
method: 'POST',
path: '/graphql',
config,
handler
});

if (graphiql) {
server.route({
method: 'GET',
path: '/graphql',
config,
handler
});
}
Expand Down

0 comments on commit f07a7a7

Please sign in to comment.