Apollo-server: Hapi example returns "GET query missing"

Created on 19 Mar 2018  ·  3Comments  ·  Source: apollographql/apollo-server

I'm just evaluating apollo-server Hapi plugin and the /grapql query returns:

{"statusCode":400,"error":"Bad Request","message":"GET query missing."}

I've posted here the sample code that does not work for me:

Thanks for your support!
Attilio

🖇️ hapi

Most helpful comment

use playground: true,
const server = new ApolloServer({ introspection: true, playground: true, typeDefs, resolvers, })

All 3 comments

As the error decription suggest my query was wrong. Using something like:

http://localhost:3000/graphql?query={hello}

gives back the correct result.

I (wrongly) expected that the graphql endpoint were a GraphiQL UI.

Reading the docs GraphiQL can be enabled with

await server.register({
  plugin: graphiqlHapi,
  options: {
    path: '/graphiql',
    graphiqlOptions: {
      endpointURL: '/graphql',
    },
  },
});

NOTE: Respect to the docs I needed to substitute register property with plugin property (hapi version 17.2.3).

I'll close this since it seems to be resolved, but let us know if we can do anything to further improve the documentation!

use playground: true,
const server = new ApolloServer({ introspection: true, playground: true, typeDefs, resolvers, })

Was this page helpful?
0 / 5 - 0 ratings