@uprtcl/graphql

Graphql schemas, resolvers and wrappers to be used with the @uprtcl infrastructure

Usage no npm install needed!

<script type="module">
  import uprtclGraphql from 'https://cdn.skypack.dev/@uprtcl/graphql';
</script>

README

@uprtcl/graphql

These are _Prtcl micro-orchestrator wrapper modules:

  • ApolloClientModule: basic module that registers the ApolloClient to be available to any external modules
  • GraphQlSchemaModule: building-block module that can extend the basic schema incldued in ApolloClientModule, with new type definitions, resolvers or directives. This lets you build whole graphql applications by composing different GraqhQl schema definitions.

Documentation

Visit our documentation site.

Install

npm install @uprtcl/graphql

Usage

Import the ApolloClientModule module and load it:

import { ApolloClientModule } from '@uprtcl/graphql';

const apolloClientModule = new ApolloClientModule(),

await orchestrator.loadModules([apolloClientModule]);

Add a new GraphQl schema to the global ApolloClient

In your module, you can declare a GraphQlSchemaModule as a submodule and add your schemas, resolvers and directives:

import { GraphQlSchemaModule } from '@uprtcl/graphql';

import { testTypeDefs } from './typeDefs';
import { resolvers } from './resolvers';

export class TestModule extends MicroModule {
  static id = Symbol('test-module');

  get submodules() {
    return [new GraphQlSchemaModule(documentsTypeDefs, resolvers)];
  }
}

And then load your module in the micro-orchestrator:

import { TestModule } from './test-module';

await orchestrator.loadModules([new TestModule()]);