New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apollo-stitcher

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-stitcher

* Apollo datasource approach to schema stitching. * Straightforward abstraction for extracting, adding and wrapping fields prior to delegation. * Per-request caching using Apollo Client.

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-89.29%
Maintainers
1
Weekly downloads
 
Created
Source

Features

  • Apollo datasource approach to schema stitching.
  • Straightforward abstraction for extracting, adding and wrapping fields prior to delegation.
  • Per-request caching using Apollo Client.

Installation

npm install graphql apollo-stitcher

Resources

Repository: yaacovCR/apollo-stitcher

API: yaacovcr.github.io/apollo-stitcher

Demo: yaacovCR/nextjs-graphql-starter

Quick Start

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',
      args: {
        objects: [args]
      }
    });
  }
}

...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
  });

FAQs

Package last updated on 21 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc