graphiQL function

RequestHandler graphiQL({
  1. String graphQLEndpoint = '/graphql',
  2. String? subscriptionsEndpoint,
})

Returns a simple RequestHandler that renders the GraphiQL visual interface for GraphQL.

By default, the interface expects your backend to be mounted at /graphql; this is configurable via graphQLEndpoint.

Implementation

RequestHandler graphiQL(
    {String graphQLEndpoint = '/graphql', String? subscriptionsEndpoint}) {
  return (req, res) {
    res
      ..contentType = MediaType('text', 'html')
      ..write(renderGraphiql(
          graphqlEndpoint: graphQLEndpoint,
          subscriptionsEndpoint: subscriptionsEndpoint))
      ..close();
  };
}