by Milo

graphql-compose is a type registry and toolkit for programmatically constructing, extending, and modifying GraphQL schemas. Ideal for developers building schema generators, plugins, or wrapping existing data sources like MongoDB, REST APIs, or ElasticSearch.
graphql-compose is a programmatic GraphQL schema construction library that provides a type registry, composer classes for all GraphQL type kinds, and a Resolver abstraction for named field configs. It is aimed at developers building schema generators, ORM integrations, or any tool that needs to dynamically create, extend, or modify GraphQL schemas in TypeScript/Node.js projects.
__mocks__/ - Jest mock for SchemaComposer used in teststype/ - Extra scalar types: GraphQLDate, GraphQLBuffer, GraphQLJSON, GraphQLJSONObjectutils/ - Internal utility functions (projection, type helpers, schema printing, deep merge, etc.)EnumTypeComposer.ts - Composer for GraphQL enum typesInputTypeComposer.ts - Composer for GraphQL input object typesInterfaceTypeComposer.ts - Composer for GraphQL interface typesListComposer.ts - Wraps any type composer in a GraphQL ListNonNullComposer.ts - Wraps any type composer in a GraphQL NonNullObjectTypeComposer.ts - Composer for GraphQL object output typesResolver.ts - Named, composable field config with middleware supportScalarTypeComposer.ts - Composer for GraphQL scalar typesSchemaComposer.ts - Central type registry; entry point for building schemasThunkComposer.ts - Wraps a thunk-deferred type for circular reference handlingTypeMapper.ts - Parses SDL strings and maps them to composer instancesTypeStorage.ts - Internal key-value store for registered typesUnionTypeComposer.ts - Composer for GraphQL union typesgraphql.ts - Re-exports from the graphql peer dependencyindex.ts - Main public barrel exporttype/buffer.ts - GraphQLBuffer scalar implementationtype/date.ts - GraphQLDate scalar implementationtype/index.ts - Aggregates and exports custom scalar typesnpm install graphql-compose graphql graphql-type-json
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript cli / script completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 87e4465f7079a8ba…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
No native modules, iOS pod installs, Android linking, or Expo prebuild steps are required. This is a pure Node.js library.
Drop the source/ directory into your project, e.g. at src/graphql-compose/.
In tsconfig.json, ensure moduleResolution is set to node or bundler and that esModuleInterop is true:
{
"compilerOptions": {
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true
}
}
source/ rather than the npm package, add a path alias:{
"compilerOptions": {
"paths": {
"graphql-compose": ["./src/graphql-compose/index.ts"]
}
}
}
When using the npm package directly (recommended), simply install per the dependencies section and import from graphql-compose. No environment variables are required.
Ensure your installed graphql version is compatible (graphql-compose targets graphql v15/v16). Pin a single version to avoid duplicate graphql package issues.
import { SchemaComposer } from 'graphql-compose';
const sc = new SchemaComposer<MyContext>();
The central registry. Create object types, input types, enums, scalars, unions, and interfaces through its create*TC methods. Call sc.buildSchema() to produce a GraphQLSchema. Use the exported schemaComposer singleton for single-schema projects or instantiate your own for multi-schema or test isolation scenarios.
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
const sc = new SchemaComposer();
const UserTC: ObjectTypeComposer = sc.createObjectTC({ name: 'User', fields: { id: 'ID!', name: 'String!' } });
Wraps a GraphQLObjectType and exposes methods to add, remove, reorder, and modify fields and arguments, attach interfaces, add Resolvers, and convert the type to an input equivalent. Use when you need to build or modify object output types programmatically.
import { Resolver, SchemaComposer } from 'graphql-compose';
const sc = new SchemaComposer();
const findUser = new Resolver({
name: 'findUser',
type: 'User',
args: { id: 'ID!' },
resolve: async ({ args, context }) => { /* ... */ },
}, sc);
A named, reusable field config that encapsulates type, args, and resolve function. Resolvers can be composed with .wrap(), .wrapResolve(), and middleware chains. Use them to define data-fetching logic separately from the schema shape, then attach to types with UserTC.addResolver(findUser).
import { InterfaceTypeComposer, SchemaComposer } from 'graphql-compose';
const sc = new SchemaComposer();
const NodeITC: InterfaceTypeComposer = sc.createInterfaceTC({ name: 'Node', fields: { id: 'ID!' } });
Wraps GraphQLInterfaceType and supports the same field manipulation API as ObjectTypeComposer. Use when multiple object types share a common field contract.
Create two related types, wire a query, and build a GraphQLSchema ready to pass to an HTTP server.
import { SchemaComposer } from 'graphql-compose';
const sc = new SchemaComposer();
const PostTC = sc.createObjectTC({
name: 'Post',
fields: {
id: 'ID!',
title: 'String!',
body: 'String',
},
});
const AuthorTC = sc.createObjectTC({
name: 'Author',
fields: {
id: 'ID!',
name: 'String!',
posts: { type: () => [PostTC], resolve: (author) => [] },
},
});
sc.Query.addFields({
author: {
type: AuthorTC,
args: { id: 'ID!' },
resolve: (_source, { id }) => ({ id, name: 'Alice' }),
},
});
const schema = sc.buildSchema();
// Pass `schema` to express-graphql, Apollo Server, etc.
Define a Resolver, wrap it to add logging, and attach it to a query field.
import { SchemaComposer, Resolver } from 'graphql-compose';
const sc = new SchemaComposer();
const UserTC = sc.createObjectTC({ name: 'User', fields: { id: 'ID!', email: 'String!' } });
const findUserResolver = new Resolver(
{
name: 'findUser',
type: UserTC,
args: { id: 'ID!' },
resolve: async ({ args }) => ({ id: args.id, email: 'user@example.com' }),
},
sc
);
const loggedResolver = findUserResolver.wrapResolve((next) => async (rp) => {
console.log('resolving findUser with args', rp.args);
return next(rp);
});
sc.Query.addFields({ user: loggedResolver.getFieldConfig() });
const schema = sc.buildSchema();
Incorporate built-in custom scalars and define an enum type.
import { SchemaComposer, GraphQLDate, GraphQLJSON } from 'graphql-compose';
const sc = new SchemaComposer();
sc.add(GraphQLDate);
sc.add(GraphQLJSON);
const StatusETC = sc.createEnumTC({
name: 'Status',
values: {
ACTIVE: { value: 'active' },
INACTIVE: { value: 'inactive' },
},
});
const EventTC = sc.createObjectTC({
name: 'Event',
fields: {
id: 'ID!',
createdAt: { type: () => sc.get('Date') },
metadata: { type: () => sc.get('JSON') },
status: StatusETC,
},
});
sc.Query.addFields({
event: { type: EventTC, resolve: () => ({ id: '1', createdAt: new Date(), metadata: {}, status: 'active' }) },
});
const schema = sc.buildSchema();
index.ts - Barrel file; re-exports every public class, util, and scalar. Import from here in application code.SchemaComposer.ts - Registry for all composers; provides createObjectTC, createInputTC, createEnumTC, buildSchema, and more.ObjectTypeComposer.ts - Full CRUD API over a GraphQLObjectType's fields, interfaces, directives, and extensions.InputTypeComposer.ts - Same surface as ObjectTypeComposer but for GraphQLInputObjectType.InterfaceTypeComposer.ts - Manages interface fields and the set of implementing types.UnionTypeComposer.ts - Manages union member types and type-resolver function.EnumTypeComposer.ts - Adds/removes/modifies enum values on a GraphQLEnumType.ScalarTypeComposer.ts - Thin wrapper over GraphQLScalarType for registry integration.Resolver.ts - Encapsulates type + args + resolve; supports wrapping and middleware.TypeMapper.ts - Parses SDL strings and type-definition objects into composer instances.TypeStorage.ts - Internal Map-backed store keyed by type name or constructor.ListComposer.ts - Utility wrapper that marks a composer as a List type.NonNullComposer.ts - Utility wrapper that marks a composer as NonNull.ThunkComposer.ts - Defers type resolution via thunk to break circular references.graphql.ts - Centralised re-export of graphql peer dependency to avoid version splits.type/ - Contains GraphQLDate, GraphQLBuffer, GraphQLJSON, GraphQLJSONObject scalar implementations.utils/ - Internal helpers: projection parsing, schema printing, type path traversal, deep merge, pluralize, dedent, and more.__mocks__/ - Jest mock of SchemaComposer for unit tests.graphql installations: if graphql appears in both your dependencies and a subdependency with a different version, type guards like isObjectType will fail silently. Fix: add a resolutions or overrides field in package.json to force a single version.undefined at runtime: wrap cross-referencing field types in thunk functions (() => OtherTC) so resolution is deferred until the schema is built.sc.buildSchema() throws "Query type must be provided": you must add at least one field to sc.Query before calling buildSchema().graphql-type-json is a CJS package; ensure esModuleInterop: true in tsconfig.json and that your bundler/runner supports CJS interop.sc.add(GraphQLDate) explicitly so it registers under its name in the composer registry before referencing it by string.schemaComposer singleton: the exported schemaComposer is typed SchemaComposer<any>; create a typed instance (new SchemaComposer<MyContext>()) for full context type safety.I have a copy of the graphql-compose library source in `source/` and a USAGE.md
integration guide. The upstream npm package is `graphql-compose`.
Please integrate graphql-compose into my existing TypeScript/Node.js project by
doing the following step by step:
1. Read `USAGE.md` and `source/index.ts` to understand all available exports.
2. Install required dependencies as listed in USAGE.md.
3. Create a `src/schema/index.ts` file that instantiates a `SchemaComposer`,
defines at least one ObjectTypeComposer with fields, wires it to the Query
type, and exports the built `GraphQLSchema`.
4. If I describe any custom types, enums, or resolvers, add them using the
real APIs from `source/ObjectTypeComposer.ts`, `source/Resolver.ts`,
and `source/EnumTypeComposer.ts` as shown in USAGE.md examples.
5. Add a Resolver with a `.wrapResolve()` middleware for logging.
6. Ensure `tsconfig.json` has `esModuleInterop: true` and `moduleResolution: node`.
7. Point out any circular reference risks and wrap those fields in thunks.
8. Do not invent any API methods - only use exports visible in `source/index.ts`
and documented in USAGE.md.
graphql-compose is published under the MIT License. See the upstream repository and source/LICENSE if present for the full license text. Upstream package: graphql-compose by the graphql-compose contributors.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
Automation, Utilities & Developer Tools
Free