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

0.0.3 • Public • Published

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:

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

Readme

Keywords

none

Package Sidebar

Install

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

Weekly Downloads

0

Version

0.0.3

License

UNLICENSED

Unpacked Size

29.8 kB

Total Files

24

Last publish

Collaborators

  • dcrdev
  • kaschman
  • cmbirk
  • sellry_sbir