@uprtcl/graphql
v0.1.2
Published
Graphql schemas, resolvers and wrappers to be used with the @uprtcl infrastructure
Downloads
169
Readme
@uprtcl/graphql
These are _Prtcl micro-orchestrator
wrapper modules:
ApolloClientModule
: basic module that registers theApolloClient
to be available to any external modulesGraphQlSchemaModule
: building-block module that can extend the basic schema incldued inApolloClientModule
, 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()]);