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.
createFastAPI
✓ import { createFastAPI } from 'graphql-fast-api'
✗ const createFastAPI = require('graphql-fast-api')
Default export available; named export preferred. ESM-only since v1.
defineType
✓ import { defineType } from 'graphql-fast-api'
✗ import defineType from 'graphql-fast-api'
Named export, not default. Used for defining GraphQL types in code-first approach.
GraphQLFastAPI
✓ import { GraphQLFastAPI } from 'graphql-fast-api'
✗ const GraphQLFastAPI = require('graphql-fast-api').GraphQLFastAPI
Class-based alternative; use createFastAPI factory function instead for simplicity.
Creates a minimal GraphQL server with a single hello query using type definitions and resolvers.
import { createFastAPI, defineType } from 'graphql-fast-api';
const typeDefs = defineType(`
type Query {
hello: String
}
`);
const resolvers = {
Query: {
hello: () => 'Hello, world!'
}
};
const app = createFastAPI({
schema: { typeDefs, resolvers }
});
app.listen({ port: 4000 }).then(() => {
console.log('Server running on http://localhost:4000/graphql');
});
Debug
Known issues
breakingIn v1.0.0, the createFastAPI function changed from accepting a single config object to requiring a schema property. Older usage with direct schema will break.fixUpdate to latest version and wrap resolver/handler config inside a `schema` object.
affects: <1.0.0
deprecatedThe `useGraphQLMiddleware` function is deprecated. Use `createFastAPI` with middleware plugins instead.fixReplace `useGraphQLMiddleware(app, options)` with `app.use(plugin)` where plugin is a compatible middleware plugin.
affects: >=1.0.30
gotchaResolvers must return plain objects for custom scalars; native GraphQL scalar types are automatically serialized.fixEnsure custom scalar resolvers return values that match the specified serialization format.
affects: >=1.0.0
breakingIn v1.0.45, the `subscriptions` configuration was moved from server options to a separate `subscriptions` object in the schema definition.fixMove subscription definitions inside `schema.subscriptions` instead of passing them as server options.
affects: >=1.0.45 <1.0.50
Errors
Common errors & fixes
Error: Cannot find module 'graphql-fast-api'
Package not installed or incorrect import path.
fixRun `npm install graphql-fast-api` and ensure using the correct import statement.
TypeError: createFastAPI is not a function
CommonJS require used but package is ESM-only.
fixChange to import statement: `import { createFastAPI } from 'graphql-fast-api'`. GraphQLError: Type "Query" is not defined.
Missing type definition for Query in schema.
fixEnsure your typeDefs include at least one Query type with a field.
Audit
Dependencies
graphqloptionalPeer dependency for GraphQL schema execution and type system.