Registry / api / graphi

graphi

JSON →
library9.1.1jsnpmunverified

A hapi GraphQL server plugin for version 9.1.1. Provides a simple way to integrate GraphQL with hapi, supporting schema, resolvers, GraphiQL UI, subscriptions via nes, authentication strategies, and custom error formatting. Emits pre/post resolver events. Differentiates from other hapi GraphQL plugins by offering both string and GraphQLSchema instance support, and optional resolver routes defined as hapi routes with caching and auth benefits. Stable release with moderate cadence.

npm install graphi
INSTALL
IMPORT
SIG · GRAPHI
G
graphi
apijavascriptv9.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Graphi
import Graphi from 'graphi'
const Graphi = require('graphi').default
ESM default export; in CommonJS use require('graphi') without .default
graphql
import { graphql } from 'graphi'
const graphql = require('graphql')
graphi re-exports the graphql module
makeExecutableSchema
import { makeExecutableSchema } from 'graphi'
const { makeExecutableSchema } = require('graphql-tools')
graphi provides its own makeExecutableSchema helper

Registers Graphi plugin on a hapi server with a simple schema and resolver, then starts the server.

import Graphi from 'graphi'; import Hapi from '@hapi/hapi'; const schema = ` type Query { hello: String! } `; const resolvers = { hello: () => 'world' }; const server = Hapi.server({ port: 3000 }); await server.register({ plugin: Graphi, options: { schema, resolvers } }); await server.start(); console.log('Server running on %s', server.info.uri);
Debug
Known issues
gotchaResolvers must return a Promise for async operations; graphi does not wrap non-Promise returns.
fix
Ensure all async resolvers return a Promise explicitly.
affects: >=1.0.0
gotchasubscriptionOptions are passed to nes; if nes is not registered, subscriptions will fail silently.
fix
Register nes plugin and ensure it supports the subscription options.
affects: >=1.0.0
deprecatedgraphiPath set to '' or false to disable GraphiQL UI; older docs suggested 'disabled'.
fix
Use '' or false instead of 'disabled'.
affects: >=8.0.0
gotchaauthStrategy applies to /graphql route; use graphiAuthStrategy for /graphiql. If both set to false, routes are public.
fix
Set authStrategy and graphiAuthStrategy to 'false' if no auth is needed for public endpoints.
affects: >=1.0.0
gotchaWhen using resolvers as hapi routes, routes must use method 'graphql' or have tag 'graphql' and path prefixed with '/'.
fix
Define routes with method 'graphql' or tag 'graphql' and path as '/resolverName'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'graphi'
graphi is not installed
fix
npm install graphi
TypeError: require(...).default is not a function
Incorrect import style in CommonJS (using .default)
fix
const Graphi = require('graphi'); (no .default)
Error: Schema must be a string or GraphQLSchema instance
Invalid schema type passed
fix
Ensure schema is either a string (SDL) or a GraphQLSchema object.
Upgrade
Version history
9.1.1latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency for GraphQL schema and execution
nesoptionaloptional subscription support
Agent activity
45 hits · last 30 days
node
38
OpenAI (training)
1
Resources
packagegraphi
graphi — npm install graphi · libregistry