Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sbircatalog/sbir-catalog-api-plugin-vendors

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sbircatalog/sbir-catalog-api-plugin-vendors

Proprietary Reaction Commerce Plugin for SBIR Catalog that adds Vendor functionality to the RC API

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
3
Weekly downloads
 
Created
Source

Vendors API Plugin

This plugin adds a Vendor collection to the Reaction MongoDB database and exposes GraphQL API methods for interacting with that collection. The Vendor collection stores SBIR Vendor data. Details on the Vendor entity can be found in src/simpleSchema.js.

This plugin adds the following GraqhQL queries:

  • vendor: Query for a single Vendor
  • vendorProducts: Returns Products associated with the Vendor ID
  • vendors: Query for a list of Vendors

This plugin adds the following GraqhQL mutations:

  • createVendor: Create a new Vendor
  • deleteVendor: Delete an existing Vendor
  • updateVendor: Update an existing Vendor

Getting started

Understanding Reaction Plugins

To be able to work with this plugin, you need to understand what Reaction Plugins are and how they work. Some good resources for doing so:

  • Understanding API Plugins
  • Developing the GraphQL API
  • Developing API Plugins
  • How-To: Create a new GraphQL Query
  • RC uses cursor-based pagination when returning multiple records. More info here
  • It's useful to use existing RC API plugins for reference - the products plugin is a good place to start

Local Development Strategy

Perhaps the biggest challenge in working with RC plugins is figuring out how to configure a local dev environment where you can test your changes as you code.

The suggested development strategy, which is far from perfect, is to use a submodule strategy within the reaction repo and to develop the plugin from inside the submodule of that repo. Detailed instructions:

  • Clone sellry/reaction Note: I strongly recommend you do this in some kind of 'playground' directory. Git submodules are a bit odd, and I've found best practice is to nuke this repository when you are done with it. Keep this 'playground' separate from any 'active development' repo you have for sellry/reaction
  • Within the cloned repo, add this repository as a plugin $ git submodule add [this repo via SSH or HTTPS]
  • In src/index.js of the reaction repo, import the submodule as vendorPlugin and add it to the plugins that are registered as part of the ReactionAPICore (plugins.vendors = vendorPlugin;)
  • Follow the instructions in docker-compose.dev.yml to enter development mode within reaction
  • Follow the instructions in the README to 'Start App in Docker Container'
  • Reaction should now be running via Docker with this plugin installed!

To develop in this environment:

  • cd into the sbir-catalog-api-plugin-vendors module
  • make changes as needed. To see changes live, you need to docker-compose up/down (not ideal, sorry - a docker expert could probably mount the submodule as a volume and do HMR)
  • you can commit/push/pull/branch as normal from inside the submodule inside the reaction repo.

The main benefit of this strategy is the ability to test your changes against the rest of the RC platform, finding bugs quickly without having to publish new versions of the NPM package.


Publishing new versions

  1. Update the version number in package.json
  2. Run $ npm publish

Dependencies

Babel

Babel config is pulled from @reactioncommerce/api-utils and can be found here

Reaction Plugins


Improvements List

  • Unit Testing
  • Linting
  • Local dev strategy that doesn't require full Reaction (import necessary pieces into this repo, but make sure they don't get bundled in the package, try to follow the guide here, specifically the part around @reactioncommerce/api-core)
  • Authorization (anyone can make create/update/delete)
  • admin-plugin-vendors may be desired to add a 'Vendors' tab to the RC admin tools where operators can browse various Vendors
  • fork of api-plugins with the goal of removing Vendor data from Product metadata and instead to serve that data via an additional Mongo query when Vendor data is requested on a Product

FAQs

Package last updated on 18 Feb 2021

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