Version: 0.10.x

Graphback runtime

Graphback allows you to query any data using reusable concept called runtime.

@graphback/runtime package offers way to initialize fully functional server without code generation just by supplying schema string. Runtime layer can be used for prototyping, mocking and in situation when developers want to avoid commiting generated codebase to their repository

Adding runtime layer to your application

To use runtime capabilities developers will need to create data provider.

Currently 2 data providers are supported:

  • KnexDBDataProvider
  • PgKnexDBDataProvider

Then developers can create runtime instance:

const client = new Knex(...);
const graphbackOptions = {...}
const modelString = `type Test ...`
// Create backend
const backend = new GraphQLBackendCreator(modelString, graphbackOptions);
const dbClientProvider = new PgKnexDBDataProvider(client);
const runtime = await backend.createRuntime(dbClientProvider);
console.log(runtime.schema, runtime.resolvers)

See runtime example application for more information

Adding custom resolvers to runtime

Runtime layer will come with autogenerated schema that will also include custom resolvers provided in model. Developers can append their custom resolvers to resolver array to extend runtime layer as follows.

const runtime = await backend.createRuntime(dbClientProvider);