Skip to content

Commit

Permalink
serverless plugin to validate graphql schemas using apollo managed fe…
Browse files Browse the repository at this point in the history
…deration (#1)

* plugin to upload graphql schema to managed federation service

* add readme

* fix some linting

* add comment

* remove unused package

* remove npx dependancy to fix npm audit failures

* add npm ignore

* add the ability to specify more than one graph for implementing services

* fix apollo key issue, one per graph

* fix missing packages
  • Loading branch information
Imran authored Sep 10, 2020
1 parent 5caf080 commit 8245a4e
Show file tree
Hide file tree
Showing 13 changed files with 9,621 additions and 49 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
79 changes: 79 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"env": {
"es2020": true,
"node": true,
"mocha": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 11,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-unused-vars": [
"error"
],
"prefer-const": [
"error",
{
"destructuring": "all"
}
],
"no-underscore-dangle": [
"error"
],
"no-console": "off",
"strict": [
"error",
"global"
],
"require-atomic-updates": "off",
"no-buffer-constructor": [
"error"
],
"eol-last": [
"error",
"always"
],
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"array-bracket-spacing": [
"error",
"never"
],
"space-in-parens": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.serverless
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# package directories
node_modules
jspm_packages

test
.eslintignore
.eslintrc
.gitignore
jest.config.js
README.md
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Imran

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Serverless Plugin Apollo Graphql Federation

A serverless plugin that uploads graphql schemas to Apollo managed federation. This plugin should be used in implementing services. This allows the gateway service to pull schema from apollo managed federation and also stops implementing services from uploading invalid schemas that would cause the gateway to fail.

## Usage

Install with npm

```sh
npm i -D serverless-plugin-apollo-graphql-federation
```

Add to serverless.yml

```yml
plugins:
- serverless-plugin-apollo-graphql-federation
```
```yml
service:
custom:
apolloGraphQLFederation:
graphs:
- name: 'myGraph'
apolloKey: apollo-api-key-for-my-graph
url: https://my-implementing-service/mygraphendpoint
schema: './myGraph/schema.gql',
```
## Couldn't I just use the serverless-hooks-plugin to do this?
Yes you could but this would potentially log your apolloKey in your build server logs which is undesirable.
49 changes: 0 additions & 49 deletions index.js

This file was deleted.

11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
setupFilesAfterEnv: ['./test/setup.js'],
maxWorkers: '1',
testEnvironment: 'node',
testMatch: [
'**/test/**/*test.js'
],
verbose: false
};
Loading

0 comments on commit 8245a4e

Please sign in to comment.