package
* Apollo datasource approach to schema stitching. * Straightforward abstraction for extracting, adding and wrapping fields prior to delegation. * Per-request caching using Apollo Client.
npm install apollo-stitcherGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
npm install graphql apollo-stitcher
Repository: yaacovCR/apollo-stitcher
API: yaacovcr.github.io/apollo-stitcher
Demo: yaacovCR/nextjs-graphql-starter
Extend the Stitcher class and define methods specific to your data model...
const { Stitcher, stitch } = require('apollo-stitcher');
const wrapInsert = {
selectionSet: stitch`{
affected_rows
returning {
...PreStitch
}
}`,
result: result =>
result && result.affected_rows ? result.returning[0] : null
};
class DbStitcher extends Stitcher {
delegateToInsertUser(args) {
return this.transform(wrapInsert).delegateTo({
operation: 'mutation',
fieldName: 'insert_user'
...and just add the datasource to your server.
const dataSources = () => {
return {
db: new DbStitcher({ dbSchema })
};
};Now you can just do this in your resolver:
const user = await context.dataSources.db.delegateToInsertUser({
email: lowerCaseEmail,
password: hashedPassword
});Estimated unpacked size across 29 packages.
6.3 MB
Includes dependencies.
5 direct · 3 outdated
^1.2.14
1.2.14
^1.3.4
1.3.4
^0.7.0
3.3.2
^6.0.0
11.2.6
^6.0.0
12.3.4