Moleculer Postgraphile
This package use for creating mixin for each service which can support
Usage
yarn add moleculer-postgraphile
broker;
- The mixin will create the
graphql
action for service. - To change the action name, just metion the
action
in option
schema: 'public' action: 'graphile' pgPool: ...
- To call graphql from other service:
const query = ` query { allPubPosts { nodes { id title content } } }`;const variables = {};const response = await broker;
- This mixin only create one graphql schema & service for one database schema.
- For stitching multiple schema from multiple services, use can use
introspectionQuery
;const schema = broker;
- After then, you should create custom ApolloLink which context call to:
broker;
- There is another way to discover the introspection without calling
introspectionQuery
- After creating graphql schema, the mixin will store the
introspected query
in cacher and setservice.settings.hasGraphQLSchema = true
- And will emit the event
graphile.updated
with params { schema } // schema stands for Schema Name - To get the
introspectionQuery
:
if thisbrokercacher thisbrokercacher;
- Custom cache key
;
- Available options:
; // for setting cache -> default = true}
Test
Before testing, please provision env with docker
yarn provision:dev
And then
yarn test:unit