function makeSqlmancerSchema(config: IExecutableSchemaDefinition): GraphQLSchema

Sqlmancer uses schema directives to do its magic, so these have to be added to your schema. This function is a convenient wrapper around makeExecutableSchema that does that for you. For configuration options, see here.


function createSqlmancerClient<
T extends GenericSqlmancerClient = GenericSqlmancerClient
glob: string,
knex: Knex
): T
type GenericSqlmancerClient = Knex & {
models: Record<
findById: (id: ID) => FindByIdBuilder
findMany: () => FindManyBuilder
findOne: () => FindOneBuilder
aggregate: () => AggregateBuilder
createMany?: (input: Array<any>) => CreateManyBuilder
createOne?: (input: any) => CreateOneBuilder
deleteById?: (id: ID) => DeleteByIdBuilder
deleteMany?: () => DeleteManyBuilder
updateById?: (id: ID, input: any) => UpdateByIdBuilder
updateMany?: (input: any) => UpdateManyBuilder

This function builds a database client from your type definitions and an instance of Knex. The glob pattern you provide should match the relative path of any type definitions you want Sqlmancer to parse. The type definitions may either be plain text files (for example .graphql files) or JavaScript or TypeScript files. If you target JavaScript or TypeScript files, make sure your type definitions are defined using the graphql-tag template literal tag.

The initialized client object includes a models map. Each model exposes several CRUD methods, each of which will return an appropriate query builder instance. The available methods for these query builders are described here.

If you're using TypeScript, the type for your client instance can be generated using the CLI.