From 7a545448c98e67cb1aa7ee0dcda9af89edc24798 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Tue, 4 Jan 2022 22:00:25 +0100 Subject: [PATCH 1/7] wip --- src/__tests__/depth.test.ts | 175 ++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 src/__tests__/depth.test.ts diff --git a/src/__tests__/depth.test.ts b/src/__tests__/depth.test.ts new file mode 100644 index 0000000..db37ee0 --- /dev/null +++ b/src/__tests__/depth.test.ts @@ -0,0 +1,175 @@ +import { + ASTVisitor, + buildSchema, + FieldNode, + GraphQLError, + parse, + validate, + ValidationContext +} from 'graphql' + +let countPet = 0 +let countOwner = 0 + +describe('Depth', () => { + test('If the directive is not present, ignore all aliases', () => { + function validation(context: ValidationContext): ASTVisitor { + const ast: ASTVisitor = { + OperationDefinition: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + OperationTypeDefinition: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + ObjectField: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + ObjectTypeDefinition: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + Document: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + InterfaceTypeDefinition: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + FragmentDefinition: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + FragmentSpread: (a, b, c, d, e) => { + const ctx = context + const stop = 'stop' + }, + Field: { + leave: (node: FieldNode, key, parent, path, ancestors) => { + const ctx = context + if (node.name.value === 'pet') { + const stop = 'stop' + countPet++ + } + if (node.name.value === 'owner') { + const stop = 'stop' + countOwner++ + } + if (node.name.value === 'data') { + const stop = 'stop' + // countOwner++ + } + if (node.name.value === 'getUser') { + const stop = 'stop' + // countOwner++ + } + if (node.name.value === 'admin') { + const stop = 'stop' + // countOwner++ + } + } + } + } + + return ast + } + + const schema = buildSchema(/* GraphQL */ ` + type Query { + getUser: Person + } + + interface Person { + data: Int + admin: Person + } + + type User implements Person { + data: Int + nick: String + pet: User + admin: Person + } + + type Pet implements Person { + data: Int + nick: String + owner: Person + admin: Person + } + `) + + const query = /* GraphQL */ ` + query Test { + getUser { + ...ManyUsers + data + alias_data: data + ... on Pet { + owner + alias_owner: owner + } + } + + # alias_test: getUser { + # nick + # pet { + # owner { + # pet { + # nick + # } + # } + # } + # } + } + + fragment ManyUsers on User { + data + + alias_frag: data + pet { + pet { + pet { + name + } + } + } + } + ` + + const query2 = /* GraphQL */ ` + query Test { + getUser { + # data + admin_1: admin { + alias_1: data + admin_2: admin { + alias_2: data + } + # pet { + # owner { + # nick + # } + # } + } + # pet { + # owner { + # pet { + # owner { + # pet + # } + # } + # } + # } + } + } + ` + const doc = parse(query2) + const errors = validate(schema, doc, [validation]) + // expect(errors).toHaveLength(0) + expect(true).toBeTruthy() + }) +}) From c121ca09e7a79fa8a178be6d6a59286410865a11 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Sun, 23 Jan 2022 21:03:43 +0100 Subject: [PATCH 2/7] write directive tests --- src/__tests__/depth.test.ts | 175 ------------------ .../{index.test.ts => directive.test.ts} | 2 +- src/__tests__/object-type-level.test.ts | 2 +- 3 files changed, 2 insertions(+), 177 deletions(-) delete mode 100644 src/__tests__/depth.test.ts rename src/__tests__/{index.test.ts => directive.test.ts} (99%) diff --git a/src/__tests__/depth.test.ts b/src/__tests__/depth.test.ts deleted file mode 100644 index db37ee0..0000000 --- a/src/__tests__/depth.test.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { - ASTVisitor, - buildSchema, - FieldNode, - GraphQLError, - parse, - validate, - ValidationContext -} from 'graphql' - -let countPet = 0 -let countOwner = 0 - -describe('Depth', () => { - test('If the directive is not present, ignore all aliases', () => { - function validation(context: ValidationContext): ASTVisitor { - const ast: ASTVisitor = { - OperationDefinition: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - OperationTypeDefinition: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - ObjectField: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - ObjectTypeDefinition: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - Document: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - InterfaceTypeDefinition: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - FragmentDefinition: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - FragmentSpread: (a, b, c, d, e) => { - const ctx = context - const stop = 'stop' - }, - Field: { - leave: (node: FieldNode, key, parent, path, ancestors) => { - const ctx = context - if (node.name.value === 'pet') { - const stop = 'stop' - countPet++ - } - if (node.name.value === 'owner') { - const stop = 'stop' - countOwner++ - } - if (node.name.value === 'data') { - const stop = 'stop' - // countOwner++ - } - if (node.name.value === 'getUser') { - const stop = 'stop' - // countOwner++ - } - if (node.name.value === 'admin') { - const stop = 'stop' - // countOwner++ - } - } - } - } - - return ast - } - - const schema = buildSchema(/* GraphQL */ ` - type Query { - getUser: Person - } - - interface Person { - data: Int - admin: Person - } - - type User implements Person { - data: Int - nick: String - pet: User - admin: Person - } - - type Pet implements Person { - data: Int - nick: String - owner: Person - admin: Person - } - `) - - const query = /* GraphQL */ ` - query Test { - getUser { - ...ManyUsers - data - alias_data: data - ... on Pet { - owner - alias_owner: owner - } - } - - # alias_test: getUser { - # nick - # pet { - # owner { - # pet { - # nick - # } - # } - # } - # } - } - - fragment ManyUsers on User { - data - - alias_frag: data - pet { - pet { - pet { - name - } - } - } - } - ` - - const query2 = /* GraphQL */ ` - query Test { - getUser { - # data - admin_1: admin { - alias_1: data - admin_2: admin { - alias_2: data - } - # pet { - # owner { - # nick - # } - # } - } - # pet { - # owner { - # pet { - # owner { - # pet - # } - # } - # } - # } - } - } - ` - const doc = parse(query2) - const errors = validate(schema, doc, [validation]) - // expect(errors).toHaveLength(0) - expect(true).toBeTruthy() - }) -}) diff --git a/src/__tests__/index.test.ts b/src/__tests__/directive.test.ts similarity index 99% rename from src/__tests__/index.test.ts rename to src/__tests__/directive.test.ts index 1811df7..008cad0 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/directive.test.ts @@ -1,5 +1,5 @@ import { buildSchema, GraphQLError, parse, validate } from 'graphql' -import createValidation from '../' +import createValidation from '..' describe('Directive on type field', () => { test('If the directive is not present, ignore all aliases', () => { diff --git a/src/__tests__/object-type-level.test.ts b/src/__tests__/object-type-level.test.ts index df09aa2..015f511 100644 --- a/src/__tests__/object-type-level.test.ts +++ b/src/__tests__/object-type-level.test.ts @@ -1,4 +1,4 @@ -import { buildSchema, GraphQLError, parse, validate } from 'graphql' +import { buildSchema, parse, validate } from 'graphql' import createValidation from '../' describe('Object type level validation', () => { From 76bcc986c238b45b5f094dc72af0c671f806413c Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Sun, 23 Jan 2022 21:41:29 +0100 Subject: [PATCH 3/7] convert to monorepo --- codecov.yml | 22 ++ jest.config.js | 19 +- package.json | 83 ++---- .babelrc.js => packages/no-alias/.babelrc.js | 0 .../no-alias/.eslintrc.js | 0 packages/no-alias/jest.config.js | 15 ++ packages/no-alias/package.json | 76 ++++++ .../no-alias/src}/__tests__/directive.test.ts | 0 .../src}/__tests__/object-type-level.test.ts | 2 +- .../src}/__tests__/permissions.test.ts | 2 +- {src => packages/no-alias/src}/index.ts | 0 .../no-alias/tsconfig.json | 8 +- pnpm-lock.yaml | 251 ++++++++++-------- pnpm-workspace.yaml | 2 + 14 files changed, 277 insertions(+), 203 deletions(-) create mode 100644 codecov.yml rename .babelrc.js => packages/no-alias/.babelrc.js (100%) rename .eslintrc.js => packages/no-alias/.eslintrc.js (100%) create mode 100644 packages/no-alias/jest.config.js create mode 100644 packages/no-alias/package.json rename {src => packages/no-alias/src}/__tests__/directive.test.ts (100%) rename {src => packages/no-alias/src}/__tests__/object-type-level.test.ts (98%) rename {src => packages/no-alias/src}/__tests__/permissions.test.ts (97%) rename {src => packages/no-alias/src}/index.ts (100%) rename tsconfig.json => packages/no-alias/tsconfig.json (77%) create mode 100644 pnpm-workspace.yaml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..851faf7 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,22 @@ +coverage: + status: + project: + default: + target: auto + dumba: + target: auto + flags: + - dumba + +comment: + layout: 'reach, diff, flags, files' + behavior: default + require_changes: false + require_base: true + require_head: true + +flags: + dumba: + paths: + - packages/dumba/ + carryforward: true diff --git a/jest.config.js b/jest.config.js index 042d570..afec7de 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,20 +1,15 @@ module.exports = { - testMatch: [ - '/src/**/?(*.)+(spec|test).[jt]s?(x)', - '/tests/?(*.)+(spec|test).[jt]s?(x)' - ], - testEnvironment: 'node', - moduleDirectories: ['node_modules', 'src'], + testEnvironment: 'jsdom', watchPlugins: [ 'jest-watch-typeahead/filename', 'jest-watch-typeahead/testname' ], - collectCoverageFrom: [ - '/src/**', - '!/src/globals.d.ts', - '!/src/__tests__/**', - '!/src/__fixtures__/**' - ], + globals: { + __DEV__: true, + __VERSION__: true, + __BUILD_DATE__: true, + __COMMIT_SHA__: true + }, coverageThreshold: { global: { branches: 80, diff --git a/package.json b/package.json index 99ead70..65e08af 100644 --- a/package.json +++ b/package.json @@ -1,76 +1,25 @@ { - "name": "graphql-no-alias", - "version": "1.0.1", - "private": false, - "description": "No alias directive for graphql mutation and query types. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", - "keywords": [ - "graphql", - "graphql directive", - "graphql validation", - "graphql alias", - "graphql query alias", - "graphql mutation alias" - ], - "author": "ivandotv", - "license": "MIT", - "main": "./dist/prod/graphql-no-alias.js", - "exports": { - "import": "./dist/prod/graphql-no-alias.esm.js", - "require": "./dist/prod/graphql-no-alias.js" - }, - "types": "./dist/types/index.d.ts", - "files": [ - "dist", - "src" - ], + "name": "graphql-no-alias-monorepo", + "version": "0.0.0", + "private": true, + "author": "Ivan Vlatkovic", "scripts": { - "lint": "eslint --fix \"src/**/\"", - "lint:check": "eslint \"src/**/\"", - "lint:ci": "pnpm lint:check && pnpm format:check", - "format": "prettier --write src/**", - "format:check": "prettier --check src/**", - "test": "NODE_ENV=test jest --verbose --coverage --no-cache", - "test:watch": "NODE_ENV=test jest --watch", - "test:ci": "NODE_ENV=test jest --runInBand --ci --coverage --coverageDirectory=coverage", - "build:prod": "NODE_ENV=production microbundle --tsconfig ./tsconfig.json --format modern,cjs --target node --output dist/prod", - "build": "rm -rf ./dist && pnpm build:prod", - "prepublishOnly": "pnpm build", + "test": "pnpm multi run test --workspace-concurrency 1", + "test:ci": "pnpm multi run test:ci --workspace-concurrency 1", + "lint": "pnpm multi run lint", + "lint:ci": "pnpm multi run lint:ci", + "build": "pnpm multi run build", "prepare": "husky install", - "release": "pnpm run prepublishOnly && pnpm changeset publish" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ivandotv/graphql-no-alias.git" - }, - "bugs": { - "url": "https://github.com/ivandotv/graphql-no-alias/issues" + "release": "pnpm multi run prepublishOnly --workspace-concurrency 1 && pnpm changeset publish" }, - "homepage": "https://github.com/ivandotv/graphql-no-alias#readme", - "peerDependencies": { - "graphql": "^16.2.0" + "dependencies": { + "husky": "^7.0.4", + "lint-staged": "^12.2.2", + "prettier": "^2.5.1" }, "devDependencies": { - "@babel/core": "^7.16.7", - "@babel/preset-env": "^7.16.7", - "@babel/preset-typescript": "^7.16.7", "@changesets/cli": "^2.19.0", - "@types/jest": "^27.4.0", - "@typescript-eslint/eslint-plugin": "^5.8.1", - "@typescript-eslint/parser": "^5.8.1", - "eslint": "^8.6.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-jest": "^25.3.4", - "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-promise": "^6.0.0", - "eslint-plugin-tsdoc": "^0.2.14", - "graphql": "^16.2.0", - "husky": "^7.0.4", - "jest": "^27.4.5", - "jest-mock-console": "^1.2.3", - "jest-watch-typeahead": "^1.0.0", - "lint-staged": "^12.1.4", - "microbundle": "^0.14.2", - "prettier": "^2.5.1", - "shx": "^0.3.3" + "del": "^6.0.0", + "minimist": "^1.2.5" } } diff --git a/.babelrc.js b/packages/no-alias/.babelrc.js similarity index 100% rename from .babelrc.js rename to packages/no-alias/.babelrc.js diff --git a/.eslintrc.js b/packages/no-alias/.eslintrc.js similarity index 100% rename from .eslintrc.js rename to packages/no-alias/.eslintrc.js diff --git a/packages/no-alias/jest.config.js b/packages/no-alias/jest.config.js new file mode 100644 index 0000000..6f3d55f --- /dev/null +++ b/packages/no-alias/jest.config.js @@ -0,0 +1,15 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const baseConfig = require('../../jest.config') + +module.exports = { + ...baseConfig, + rootDir: '.', + projects: undefined, + testMatch: ['/src/__tests__/?(*.)+(spec|test).[jt]s?(x)'], + collectCoverageFrom: [ + '/src/**', + '!/src/index.ts', + '!/src/__tests__/**', + '!/src/__fixtures__/**' + ] +} diff --git a/packages/no-alias/package.json b/packages/no-alias/package.json new file mode 100644 index 0000000..99ead70 --- /dev/null +++ b/packages/no-alias/package.json @@ -0,0 +1,76 @@ +{ + "name": "graphql-no-alias", + "version": "1.0.1", + "private": false, + "description": "No alias directive for graphql mutation and query types. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", + "keywords": [ + "graphql", + "graphql directive", + "graphql validation", + "graphql alias", + "graphql query alias", + "graphql mutation alias" + ], + "author": "ivandotv", + "license": "MIT", + "main": "./dist/prod/graphql-no-alias.js", + "exports": { + "import": "./dist/prod/graphql-no-alias.esm.js", + "require": "./dist/prod/graphql-no-alias.js" + }, + "types": "./dist/types/index.d.ts", + "files": [ + "dist", + "src" + ], + "scripts": { + "lint": "eslint --fix \"src/**/\"", + "lint:check": "eslint \"src/**/\"", + "lint:ci": "pnpm lint:check && pnpm format:check", + "format": "prettier --write src/**", + "format:check": "prettier --check src/**", + "test": "NODE_ENV=test jest --verbose --coverage --no-cache", + "test:watch": "NODE_ENV=test jest --watch", + "test:ci": "NODE_ENV=test jest --runInBand --ci --coverage --coverageDirectory=coverage", + "build:prod": "NODE_ENV=production microbundle --tsconfig ./tsconfig.json --format modern,cjs --target node --output dist/prod", + "build": "rm -rf ./dist && pnpm build:prod", + "prepublishOnly": "pnpm build", + "prepare": "husky install", + "release": "pnpm run prepublishOnly && pnpm changeset publish" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ivandotv/graphql-no-alias.git" + }, + "bugs": { + "url": "https://github.com/ivandotv/graphql-no-alias/issues" + }, + "homepage": "https://github.com/ivandotv/graphql-no-alias#readme", + "peerDependencies": { + "graphql": "^16.2.0" + }, + "devDependencies": { + "@babel/core": "^7.16.7", + "@babel/preset-env": "^7.16.7", + "@babel/preset-typescript": "^7.16.7", + "@changesets/cli": "^2.19.0", + "@types/jest": "^27.4.0", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-jest": "^25.3.4", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-tsdoc": "^0.2.14", + "graphql": "^16.2.0", + "husky": "^7.0.4", + "jest": "^27.4.5", + "jest-mock-console": "^1.2.3", + "jest-watch-typeahead": "^1.0.0", + "lint-staged": "^12.1.4", + "microbundle": "^0.14.2", + "prettier": "^2.5.1", + "shx": "^0.3.3" + } +} diff --git a/src/__tests__/directive.test.ts b/packages/no-alias/src/__tests__/directive.test.ts similarity index 100% rename from src/__tests__/directive.test.ts rename to packages/no-alias/src/__tests__/directive.test.ts diff --git a/src/__tests__/object-type-level.test.ts b/packages/no-alias/src/__tests__/object-type-level.test.ts similarity index 98% rename from src/__tests__/object-type-level.test.ts rename to packages/no-alias/src/__tests__/object-type-level.test.ts index 015f511..1d06fc4 100644 --- a/src/__tests__/object-type-level.test.ts +++ b/packages/no-alias/src/__tests__/object-type-level.test.ts @@ -1,5 +1,5 @@ import { buildSchema, parse, validate } from 'graphql' -import createValidation from '../' +import createValidation from '..' describe('Object type level validation', () => { test('Object level directive applies to all fields', () => { diff --git a/src/__tests__/permissions.test.ts b/packages/no-alias/src/__tests__/permissions.test.ts similarity index 97% rename from src/__tests__/permissions.test.ts rename to packages/no-alias/src/__tests__/permissions.test.ts index 7fba9a5..e1f6ee4 100644 --- a/src/__tests__/permissions.test.ts +++ b/packages/no-alias/src/__tests__/permissions.test.ts @@ -1,5 +1,5 @@ import { buildSchema, GraphQLError, parse, validate } from 'graphql' -import createValidation from '../' +import createValidation from '..' describe('Permissions via config', () => { test('Set default value for all queries', () => { diff --git a/src/index.ts b/packages/no-alias/src/index.ts similarity index 100% rename from src/index.ts rename to packages/no-alias/src/index.ts diff --git a/tsconfig.json b/packages/no-alias/tsconfig.json similarity index 77% rename from tsconfig.json rename to packages/no-alias/tsconfig.json index c35fa22..d2370a9 100644 --- a/tsconfig.json +++ b/packages/no-alias/tsconfig.json @@ -19,11 +19,11 @@ "incremental": true, "jsx": "preserve" }, - "include": ["src/**/*"], + "include": ["packages/no-alias/src/**/*"], "exclude": [ "**/node_modules", - "src/**/__tests__", - "src/**/*.test.ts", - "src/**/*.spec.ts" + "packages/no-alias/src/**/__tests__", + "packages/no-alias/src/**/*.test.ts", + "packages/no-alias/src/**/*.spec.ts" ] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a80bea..31a97bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,52 +1,71 @@ lockfileVersion: 5.3 -specifiers: - '@babel/core': ^7.16.7 - '@babel/preset-env': ^7.16.7 - '@babel/preset-typescript': ^7.16.7 - '@changesets/cli': ^2.19.0 - '@types/jest': ^27.4.0 - '@typescript-eslint/eslint-plugin': ^5.8.1 - '@typescript-eslint/parser': ^5.8.1 - eslint: ^8.6.0 - eslint-config-prettier: ^8.3.0 - eslint-plugin-jest: ^25.3.4 - eslint-plugin-prettier: ^4.0.0 - eslint-plugin-promise: ^6.0.0 - eslint-plugin-tsdoc: ^0.2.14 - graphql: ^16.2.0 - husky: ^7.0.4 - jest: ^27.4.5 - jest-mock-console: ^1.2.3 - jest-watch-typeahead: ^1.0.0 - lint-staged: ^12.1.4 - microbundle: ^0.14.2 - prettier: ^2.5.1 - shx: ^0.3.3 - -devDependencies: - '@babel/core': 7.16.7 - '@babel/preset-env': 7.16.7_@babel+core@7.16.7 - '@babel/preset-typescript': 7.16.7_@babel+core@7.16.7 - '@changesets/cli': 2.19.0 - '@types/jest': 27.4.0 - '@typescript-eslint/eslint-plugin': 5.8.1_6e71998ecdb938417ab1e2ca4e024f09 - '@typescript-eslint/parser': 5.8.1_eslint@8.6.0 - eslint: 8.6.0 - eslint-config-prettier: 8.3.0_eslint@8.6.0 - eslint-plugin-jest: 25.3.4_cac5dc51ed5a5c1ae220309c27c6e099 - eslint-plugin-prettier: 4.0.0_1c588f61426b1faf18812943f1678311 - eslint-plugin-promise: 6.0.0_eslint@8.6.0 - eslint-plugin-tsdoc: 0.2.14 - graphql: 16.2.0 - husky: 7.0.4 - jest: 27.4.5 - jest-mock-console: 1.2.3_jest@27.4.5 - jest-watch-typeahead: 1.0.0_jest@27.4.5 - lint-staged: 12.1.4 - microbundle: 0.14.2 - prettier: 2.5.1 - shx: 0.3.3 +importers: + + .: + specifiers: + '@changesets/cli': ^2.19.0 + del: ^6.0.0 + husky: ^7.0.4 + lint-staged: ^12.2.2 + minimist: ^1.2.5 + prettier: ^2.5.1 + dependencies: + husky: 7.0.4 + lint-staged: 12.3.1 + prettier: 2.5.1 + devDependencies: + '@changesets/cli': 2.19.0 + del: 6.0.0 + minimist: 1.2.5 + + packages/no-alias: + specifiers: + '@babel/core': ^7.16.7 + '@babel/preset-env': ^7.16.7 + '@babel/preset-typescript': ^7.16.7 + '@changesets/cli': ^2.19.0 + '@types/jest': ^27.4.0 + '@typescript-eslint/eslint-plugin': ^5.8.1 + '@typescript-eslint/parser': ^5.8.1 + eslint: ^8.6.0 + eslint-config-prettier: ^8.3.0 + eslint-plugin-jest: ^25.3.4 + eslint-plugin-prettier: ^4.0.0 + eslint-plugin-promise: ^6.0.0 + eslint-plugin-tsdoc: ^0.2.14 + graphql: ^16.2.0 + husky: ^7.0.4 + jest: ^27.4.5 + jest-mock-console: ^1.2.3 + jest-watch-typeahead: ^1.0.0 + lint-staged: ^12.1.4 + microbundle: ^0.14.2 + prettier: ^2.5.1 + shx: ^0.3.3 + devDependencies: + '@babel/core': 7.16.7 + '@babel/preset-env': 7.16.7_@babel+core@7.16.7 + '@babel/preset-typescript': 7.16.7_@babel+core@7.16.7 + '@changesets/cli': 2.19.0 + '@types/jest': 27.4.0 + '@typescript-eslint/eslint-plugin': 5.8.1_6e71998ecdb938417ab1e2ca4e024f09 + '@typescript-eslint/parser': 5.8.1_eslint@8.6.0 + eslint: 8.6.0 + eslint-config-prettier: 8.3.0_eslint@8.6.0 + eslint-plugin-jest: 25.3.4_cac5dc51ed5a5c1ae220309c27c6e099 + eslint-plugin-prettier: 4.0.0_1c588f61426b1faf18812943f1678311 + eslint-plugin-promise: 6.0.0_eslint@8.6.0 + eslint-plugin-tsdoc: 0.2.14 + graphql: 16.2.0 + husky: 7.0.4 + jest: 27.4.5 + jest-mock-console: 1.2.3_jest@27.4.5 + jest-watch-typeahead: 1.0.0_jest@27.4.5 + lint-staged: 12.1.4 + microbundle: 0.14.2 + prettier: 2.5.1 + shx: 0.3.3 packages: @@ -2202,7 +2221,6 @@ packages: dependencies: clean-stack: 2.2.0 indent-string: 4.0.0 - dev: true /ajv/6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} @@ -2233,7 +2251,6 @@ packages: engines: {node: '>=8'} dependencies: type-fest: 0.21.3 - dev: true /ansi-regex/2.1.1: resolution: {integrity: sha1-w7M6te42DYbg5ijwRorn7yfWVN8=} @@ -2248,12 +2265,10 @@ packages: /ansi-regex/5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - dev: true /ansi-regex/6.0.1: resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} engines: {node: '>=12'} - dev: true /ansi-styles/2.2.1: resolution: {integrity: sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=} @@ -2272,7 +2287,6 @@ packages: engines: {node: '>=8'} dependencies: color-convert: 2.0.1 - dev: true /ansi-styles/5.2.0: resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} @@ -2282,7 +2296,6 @@ packages: /ansi-styles/6.1.0: resolution: {integrity: sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ==} engines: {node: '>=12'} - dev: true /anymatch/3.1.2: resolution: {integrity: sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==} @@ -2315,7 +2328,6 @@ packages: /astral-regex/2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} - dev: true /async/0.9.2: resolution: {integrity: sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=} @@ -2522,7 +2534,6 @@ packages: engines: {node: '>=8'} dependencies: fill-range: 7.0.1 - dev: true /breakword/1.0.5: resolution: {integrity: sha512-ex5W9DoOQ/LUEU3PMdLs9ua/CYZl1678NUkKOdUSi8Aw5F1idieaiRURCBFJCwVcrD1J8Iy3vfWSloaMwO2qFg==} @@ -2678,7 +2689,6 @@ packages: /clean-stack/2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} - dev: true /cli-boxes/1.0.0: resolution: {integrity: sha1-T6kXw+WclKAEzWH47lCdplFocUM=} @@ -2690,7 +2700,6 @@ packages: engines: {node: '>=8'} dependencies: restore-cursor: 3.1.0 - dev: true /cli-truncate/2.1.0: resolution: {integrity: sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==} @@ -2698,7 +2707,6 @@ packages: dependencies: slice-ansi: 3.0.0 string-width: 4.2.3 - dev: true /cli-truncate/3.1.0: resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} @@ -2706,7 +2714,6 @@ packages: dependencies: slice-ansi: 5.0.0 string-width: 5.0.1 - dev: true /cliui/6.0.0: resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==} @@ -2749,7 +2756,6 @@ packages: engines: {node: '>=7.0.0'} dependencies: color-name: 1.1.4 - dev: true /color-name/1.1.3: resolution: {integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=} @@ -2757,7 +2763,6 @@ packages: /color-name/1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true /colord/2.9.2: resolution: {integrity: sha512-Uqbg+J445nc1TKn4FoDPS6ZZqAvEDnwrH42yo8B40JSOgSLxMZ/gt3h4nmCtPLQeXhjJJkqBx7SCY35WnIixaQ==} @@ -2765,7 +2770,6 @@ packages: /colorette/2.0.16: resolution: {integrity: sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==} - dev: true /combined-stream/1.0.8: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} @@ -2786,7 +2790,6 @@ packages: /commander/8.3.0: resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} engines: {node: '>= 12'} - dev: true /commondir/1.0.1: resolution: {integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=} @@ -2841,7 +2844,6 @@ packages: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 - dev: true /css-declaration-sorter/6.1.3_postcss@8.4.5: resolution: {integrity: sha512-SvjQjNRZgh4ULK1LDJ2AduPKUKxIqmtU7ZAyi47BTV+M90Qvxr9AB6lKlLbDUfXqI9IQeYA8LbAsCZPpJEV3aA==} @@ -3017,7 +3019,6 @@ packages: dependencies: ms: 2.1.2 supports-color: 9.2.1 - dev: true /decamelize-keys/1.1.0: resolution: {integrity: sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=} @@ -3062,6 +3063,20 @@ packages: object-keys: 1.1.1 dev: true + /del/6.0.0: + resolution: {integrity: sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==} + engines: {node: '>=10'} + dependencies: + globby: 11.0.4 + graceful-fs: 4.2.8 + is-glob: 4.0.3 + is-path-cwd: 2.2.0 + is-path-inside: 3.0.3 + p-map: 4.0.0 + rimraf: 3.0.2 + slash: 3.0.0 + dev: true + /delayed-stream/1.0.0: resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} engines: {node: '>=0.4.0'} @@ -3157,11 +3172,9 @@ packages: /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true /emoji-regex/9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - dev: true /enquirer/2.3.6: resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} @@ -3481,7 +3494,6 @@ packages: onetime: 5.1.2 signal-exit: 3.0.6 strip-final-newline: 2.0.0 - dev: true /exit/0.1.2: resolution: {integrity: sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=} @@ -3583,7 +3595,6 @@ packages: engines: {node: '>=8'} dependencies: to-regex-range: 5.0.1 - dev: true /find-cache-dir/3.3.2: resolution: {integrity: sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==} @@ -3717,7 +3728,6 @@ packages: /get-stream/6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} - dev: true /get-symbol-description/1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} @@ -3899,13 +3909,11 @@ packages: /human-signals/2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} - dev: true /husky/7.0.4: resolution: {integrity: sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==} engines: {node: '>=12'} hasBin: true - dev: true /iconv-lite/0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} @@ -3976,7 +3984,6 @@ packages: /indent-string/4.0.0: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} - dev: true /inflight/1.0.6: resolution: {integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=} @@ -4059,12 +4066,10 @@ packages: /is-fullwidth-code-point/3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} - dev: true /is-fullwidth-code-point/4.0.0: resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} engines: {node: '>=12'} - dev: true /is-generator-fn/2.1.0: resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} @@ -4097,6 +4102,15 @@ packages: /is-number/7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} + + /is-path-cwd/2.2.0: + resolution: {integrity: sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==} + engines: {node: '>=6'} + dev: true + + /is-path-inside/3.0.3: + resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} + engines: {node: '>=8'} dev: true /is-plain-obj/1.1.0: @@ -4134,7 +4148,6 @@ packages: /is-stream/2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} - dev: true /is-string/1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} @@ -4174,7 +4187,6 @@ packages: /isexe/2.0.0: resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=} - dev: true /istanbul-lib-coverage/3.2.0: resolution: {integrity: sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==} @@ -4890,7 +4902,6 @@ packages: /lilconfig/2.0.4: resolution: {integrity: sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==} engines: {node: '>=10'} - dev: true /lines-and-columns/1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -4918,6 +4929,28 @@ packages: - enquirer dev: true + /lint-staged/12.3.1: + resolution: {integrity: sha512-Ocht/eT+4/siWOZDJpNUKcKX2UeWW/pDbohJ4gRsrafAjBi79JK8kiNVk2ciIVNKdw0Q4ABptl2nr6uQAlRImw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + hasBin: true + dependencies: + cli-truncate: 3.1.0 + colorette: 2.0.16 + commander: 8.3.0 + debug: 4.3.3_supports-color@9.2.1 + execa: 5.1.1 + lilconfig: 2.0.4 + listr2: 4.0.1 + micromatch: 4.0.4 + normalize-path: 3.0.0 + object-inspect: 1.12.0 + string-argv: 0.3.1 + supports-color: 9.2.1 + yaml: 1.10.2 + transitivePeerDependencies: + - enquirer + dev: false + /listr2/3.13.5: resolution: {integrity: sha512-3n8heFQDSk+NcwBn3CgxEibZGaRzx+pC64n3YjpMD1qguV4nWus3Al+Oo3KooqFKTQEJ1v7MmnbnyyNspgx3NA==} engines: {node: '>=10.0.0'} @@ -4932,11 +4965,30 @@ packages: log-update: 4.0.0 p-map: 4.0.0 rfdc: 1.3.0 - rxjs: 7.5.1 + rxjs: 7.5.2 through: 2.3.8 wrap-ansi: 7.0.0 dev: true + /listr2/4.0.1: + resolution: {integrity: sha512-D65Nl+zyYHL2jQBGmxtH/pU8koPZo5C8iCNE8EoB04RwPgQG1wuaKwVbeZv9LJpiH4Nxs0FCp+nNcG8OqpniiA==} + engines: {node: '>=12'} + peerDependencies: + enquirer: '>= 2.3.0 < 3' + peerDependenciesMeta: + enquirer: + optional: true + dependencies: + cli-truncate: 2.1.0 + colorette: 2.0.16 + log-update: 4.0.0 + p-map: 4.0.0 + rfdc: 1.3.0 + rxjs: 7.5.2 + through: 2.3.8 + wrap-ansi: 7.0.0 + dev: false + /load-yaml-file/0.2.0: resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==} engines: {node: '>=6'} @@ -5002,7 +5054,6 @@ packages: cli-cursor: 3.1.0 slice-ansi: 4.0.0 wrap-ansi: 6.2.0 - dev: true /lru-cache/4.1.5: resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} @@ -5080,7 +5131,6 @@ packages: /merge-stream/2.0.0: resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: true /merge2/1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} @@ -5145,7 +5195,6 @@ packages: dependencies: braces: 3.0.2 picomatch: 2.3.0 - dev: true /mime-db/1.51.0: resolution: {integrity: sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==} @@ -5162,7 +5211,6 @@ packages: /mimic-fn/2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} - dev: true /min-indent/1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} @@ -5200,7 +5248,6 @@ packages: /ms/2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true /nanoid/3.1.30: resolution: {integrity: sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==} @@ -5232,7 +5279,6 @@ packages: /normalize-path/3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - dev: true /normalize-range/0.1.2: resolution: {integrity: sha1-LRDAa9/TEuqXd2laTShDlFa3WUI=} @@ -5256,7 +5302,6 @@ packages: engines: {node: '>=8'} dependencies: path-key: 3.1.1 - dev: true /nth-check/2.0.1: resolution: {integrity: sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==} @@ -5280,7 +5325,6 @@ packages: /object-inspect/1.12.0: resolution: {integrity: sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==} - dev: true /object-keys/1.1.1: resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} @@ -5308,7 +5352,6 @@ packages: engines: {node: '>=6'} dependencies: mimic-fn: 2.1.0 - dev: true /optionator/0.8.3: resolution: {integrity: sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==} @@ -5393,7 +5436,6 @@ packages: engines: {node: '>=10'} dependencies: aggregate-error: 3.1.0 - dev: true /p-queue/6.6.2: resolution: {integrity: sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==} @@ -5454,7 +5496,6 @@ packages: /path-key/3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} - dev: true /path-parse/1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -5472,7 +5513,6 @@ packages: /picomatch/2.3.0: resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==} engines: {node: '>=8.6'} - dev: true /pify/4.0.1: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} @@ -5912,7 +5952,6 @@ packages: resolution: {integrity: sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==} engines: {node: '>=10.13.0'} hasBin: true - dev: true /pretty-bytes/3.0.1: resolution: {integrity: sha1-J9AAjXeAY6C0gRuzXHnxvV1fvM8=} @@ -6144,7 +6183,6 @@ packages: dependencies: onetime: 5.1.2 signal-exit: 3.0.6 - dev: true /reusify/1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} @@ -6153,7 +6191,6 @@ packages: /rfdc/1.3.0: resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==} - dev: true /rimraf/3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} @@ -6242,11 +6279,10 @@ packages: queue-microtask: 1.2.3 dev: true - /rxjs/7.5.1: - resolution: {integrity: sha512-KExVEeZWxMZnZhUZtsJcFwz8IvPvgu4G2Z2QyqjZQzUGr32KDYuSxrEYO4w3tFFNbfLozcrKUTvTPi+E9ywJkQ==} + /rxjs/7.5.2: + resolution: {integrity: sha512-PwDt186XaL3QN5qXj/H9DGyHhP3/RYYgZZwqBv9Tv8rsAaiwFH1IsJJlcgD37J7UW5a6O67qX0KWKS3/pu0m4w==} dependencies: tslib: 2.3.1 - dev: true /sade/1.8.0: resolution: {integrity: sha512-NRfCA8AVYuAA7Hu8bs18od6J4BdcXXwOv6OJuNgwbw8LcLK8JKwaM3WckLZ+MGyPJUS/ivVgK3twltrOIJJnug==} @@ -6323,7 +6359,6 @@ packages: engines: {node: '>=8'} dependencies: shebang-regex: 3.0.0 - dev: true /shebang-regex/1.0.0: resolution: {integrity: sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=} @@ -6333,7 +6368,6 @@ packages: /shebang-regex/3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} - dev: true /shelljs/0.8.4: resolution: {integrity: sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==} @@ -6364,7 +6398,6 @@ packages: /signal-exit/3.0.6: resolution: {integrity: sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ==} - dev: true /sisteransi/1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} @@ -6387,7 +6420,6 @@ packages: ansi-styles: 4.3.0 astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 - dev: true /slice-ansi/4.0.0: resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} @@ -6396,7 +6428,6 @@ packages: ansi-styles: 4.3.0 astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 - dev: true /slice-ansi/5.0.0: resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} @@ -6404,7 +6435,6 @@ packages: dependencies: ansi-styles: 6.1.0 is-fullwidth-code-point: 4.0.0 - dev: true /smartwrap/1.2.5: resolution: {integrity: sha512-bzWRwHwu0RnWjwU7dFy7tF68pDAx/zMSu3g7xr9Nx5J0iSImYInglwEVExyHLxXljy6PWMjkSAbwF7t2mPnRmg==} @@ -6502,7 +6532,6 @@ packages: /string-argv/0.3.1: resolution: {integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==} engines: {node: '>=0.6.19'} - dev: true /string-hash/1.1.3: resolution: {integrity: sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=} @@ -6539,7 +6568,6 @@ packages: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - dev: true /string-width/5.0.1: resolution: {integrity: sha512-5ohWO/M4//8lErlUUtrFy3b11GtNOuMOU0ysKCDXFcfXuuvUXu95akgj/i8ofmaGdN0hCqyl6uu9i8dS/mQp5g==} @@ -6548,7 +6576,6 @@ packages: emoji-regex: 9.2.2 is-fullwidth-code-point: 4.0.0 strip-ansi: 7.0.1 - dev: true /string.prototype.matchall/4.0.6: resolution: {integrity: sha512-6WgDX8HmQqvEd7J+G6VtAahhsQIssiZ8zl7zKh1VDMFyL3hRTJP4FTNA3RbIp2TOQ9AYNDcc7e3fH0Qbup+DBg==} @@ -6596,14 +6623,12 @@ packages: engines: {node: '>=8'} dependencies: ansi-regex: 5.0.1 - dev: true /strip-ansi/7.0.1: resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==} engines: {node: '>=12'} dependencies: ansi-regex: 6.0.1 - dev: true /strip-bom/3.0.0: resolution: {integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=} @@ -6623,7 +6648,6 @@ packages: /strip-final-newline/2.0.0: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} - dev: true /strip-indent/3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} @@ -6681,7 +6705,6 @@ packages: /supports-color/9.2.1: resolution: {integrity: sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ==} engines: {node: '>=12'} - dev: true /supports-hyperlinks/2.2.0: resolution: {integrity: sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ==} @@ -6763,7 +6786,6 @@ packages: /through/2.3.8: resolution: {integrity: sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=} - dev: true /timsort/0.3.0: resolution: {integrity: sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=} @@ -6797,7 +6819,6 @@ packages: engines: {node: '>=8.0'} dependencies: is-number: 7.0.0 - dev: true /tough-cookie/4.0.0: resolution: {integrity: sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==} @@ -6830,7 +6851,6 @@ packages: /tslib/2.3.1: resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==} - dev: true /tsutils/3.21.0: resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} @@ -6886,7 +6906,6 @@ packages: /type-fest/0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} - dev: true /type-fest/0.6.0: resolution: {integrity: sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==} @@ -7066,7 +7085,6 @@ packages: hasBin: true dependencies: isexe: 2.0.0 - dev: true /widest-line/2.0.1: resolution: {integrity: sha512-Ba5m9/Fa4Xt9eb2ELXt77JxVDV8w7qQrH0zS/TWSJdLyAwQjWoOzpzj5lwVftDz6n/EOu3tNACS84v509qwnJA==} @@ -7087,7 +7105,6 @@ packages: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true /wrap-ansi/7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} @@ -7096,7 +7113,6 @@ packages: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true /wrappy/1.0.2: resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=} @@ -7152,7 +7168,6 @@ packages: /yaml/1.10.2: resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==} engines: {node: '>= 6'} - dev: true /yargs-parser/18.1.3: resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..18ec407 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - 'packages/*' From 3862e3d349923ba31082988c2f553821d9ce4b11 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Sun, 23 Jan 2022 22:12:29 +0100 Subject: [PATCH 4/7] fix monorepo setup --- .vscode/launch.json | 27 ++++--- codecov.yml | 8 +- packages/envelop/.babelrc.js | 17 ++++ packages/envelop/.eslintrc.js | 81 +++++++++++++++++++ packages/envelop/jest.config.js | 15 ++++ packages/envelop/package.json | 82 +++++++++++++++++++ packages/no-alias/package.json | 7 +- pnpm-lock.yaml | 135 +++++++++++++++++++++++--------- 8 files changed, 315 insertions(+), 57 deletions(-) create mode 100644 packages/envelop/.babelrc.js create mode 100644 packages/envelop/.eslintrc.js create mode 100644 packages/envelop/jest.config.js create mode 100644 packages/envelop/package.json diff --git a/.vscode/launch.json b/.vscode/launch.json index a65bbb5..9bd3d60 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,12 +17,12 @@ ] }, { - "name": "Current test file", + "name": "no alias test file", "type": "node", "request": "launch", "cwd": "${workspaceRoot}", // "program": "${workspaceFolder}/node_modules/.bin/jest", - "program": "${workspaceFolder}/node_modules/jest/bin/jest.js", //pnpm fix + "program": "${workspaceFolder}/packages/no-alias/node_modules/jest/bin/jest.js", //pnpm fix "args": [ "${relativeFile}", "--no-cache", @@ -39,19 +39,26 @@ ] }, { - "name": "Nodemon", + "name": "Envelop test file", "type": "node", - "request": "attach", - "processId": "${command:PickProcess}", - "restart": true, + "request": "launch", + "cwd": "${workspaceFolder}/packages/envelop", + // "program": "${workspaceFolder}/node_modules/.bin/jest", + "program": "${workspaceFolder}/packages/envelop/node_modules/jest/bin/jest.js", //pnpm fix + "args": [ + "${relativeFile}", + "--no-cache", + "--watchAll=false", + "--runInBand" + ], + "console": "integratedTerminal", "protocol": "inspector", + "internalConsoleOptions": "neverOpen", + "disableOptimisticBPs": true, "skipFiles": [ "${workspaceFolder}/node_modules/**/*.js", "/**/*.js" - ], - // "localRoot": "${workspaceFolder}/src/regexparam", - // "remoteRoot": "/", - "stopOnEntry": true + ] } ] } diff --git a/codecov.yml b/codecov.yml index 851faf7..0d6d8f9 100644 --- a/codecov.yml +++ b/codecov.yml @@ -3,10 +3,10 @@ coverage: project: default: target: auto - dumba: + graphql-no-alias: target: auto flags: - - dumba + - graphql-no-alias comment: layout: 'reach, diff, flags, files' @@ -16,7 +16,7 @@ comment: require_head: true flags: - dumba: + graphql-no-alias: paths: - - packages/dumba/ + - packages/graphql-no-alias/ carryforward: true diff --git a/packages/envelop/.babelrc.js b/packages/envelop/.babelrc.js new file mode 100644 index 0000000..2deee84 --- /dev/null +++ b/packages/envelop/.babelrc.js @@ -0,0 +1,17 @@ +const jestConfig = { + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current' + } + } + ], + '@babel/preset-typescript' + ], + ignore: ['node_modules'], + sourceMaps: 'inline' +} + +module.exports = process.env.NODE_ENV === 'test' ? jestConfig : {} diff --git a/packages/envelop/.eslintrc.js b/packages/envelop/.eslintrc.js new file mode 100644 index 0000000..6094d53 --- /dev/null +++ b/packages/envelop/.eslintrc.js @@ -0,0 +1,81 @@ +module.exports = { + root: true, + env: { + es6: true, + node: true, + jest: true + }, + plugins: [ + 'eslint-plugin-tsdoc', + '@typescript-eslint/eslint-plugin', + 'prettier' + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:jest/recommended', + 'prettier' + ], + parser: '@typescript-eslint/parser', + parserOptions: { + sourceType: 'module' + }, + rules: { + 'tsdoc/syntax': 'warn', + '@typescript-eslint/no-unused-vars': ['off', { argsIgnorePattern: '^_' }], + 'generator-star-spacing': ['error', { before: false, after: true }], + 'space-before-function-paren': 'off', + 'no-dupe-class-members': 'off', + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'off', + 'prettier/prettier': ['error'], + 'lines-between-class-members': ['error', 'always'], + 'padding-line-between-statements': [ + 'error', + { blankLine: 'always', prev: '*', next: 'return' } + ], + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/explicit-function-return-type': [ + 'error', + { + allowExpressions: true, + allowTypedFunctionExpressions: true + } + ], + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + accessibility: 'no-public' + } + ], + '@typescript-eslint/ban-ts-comment': [ + 'error', + { + 'ts-expect-error': 'allow-with-description' + } + ], + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/member-delimiter-style': [ + 'error', + { + multiline: { + delimiter: 'none', + requireLast: false + }, + singleline: { + delimiter: 'semi', + requireLast: false + } + } + ] + }, + overrides: [ + { + files: ['*.js', '*.jsx'], + rules: { + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/no-var-requires': 'off' + } + } + ] +} diff --git a/packages/envelop/jest.config.js b/packages/envelop/jest.config.js new file mode 100644 index 0000000..6f3d55f --- /dev/null +++ b/packages/envelop/jest.config.js @@ -0,0 +1,15 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const baseConfig = require('../../jest.config') + +module.exports = { + ...baseConfig, + rootDir: '.', + projects: undefined, + testMatch: ['/src/__tests__/?(*.)+(spec|test).[jt]s?(x)'], + collectCoverageFrom: [ + '/src/**', + '!/src/index.ts', + '!/src/__tests__/**', + '!/src/__fixtures__/**' + ] +} diff --git a/packages/envelop/package.json b/packages/envelop/package.json new file mode 100644 index 0000000..8cb69f3 --- /dev/null +++ b/packages/envelop/package.json @@ -0,0 +1,82 @@ +{ + "name": "envelop-no-alias", + "version": "1.0.1", + "private": false, + "description": "Graphql envelop plugin for no alias directive for graphql mutation and query types. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", + "keywords": [ + "@envelop", + "envelop", + "graphql", + "graphql directive", + "graphql validation", + "graphql alias", + "graphql query alias", + "graphql mutation alias" + ], + "author": "ivandotv", + "license": "MIT", + "main": "./dist/prod/envelop-no-alias.js", + "exports": { + "import": "./dist/prod/envelop-no-alias.esm.js", + "require": "./dist/prod/envelop-no-alias.js" + }, + "types": "./dist/types/index.d.ts", + "files": [ + "dist", + "src" + ], + "scripts": { + "lint": "eslint --fix \"src/**/\"", + "lint:check": "eslint \"src/**/\"", + "lint:ci": "pnpm lint:check && pnpm format:check", + "format": "prettier --write src/**", + "format:check": "prettier --check src/**", + "test": "jest --verbose --coverage --no-cache", + "test:watch": "jest --watch", + "test:ci": "jest --runInBand --ci --coverage --coverageDirectory=coverage", + "build:prod": "NODE_ENV=production microbundle --tsconfig ./tsconfig.json --format modern,cjs --target node --output dist/prod", + "build": "rm -rf ./dist && pnpm build:prod", + "prepublishOnly": "pnpm build", + "release": "pnpm run prepublishOnly && pnpm changeset publish" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ivandotv/graphql-no-alias.git" + }, + "bugs": { + "url": "https://github.com/ivandotv/graphql-no-alias/issues" + }, + "homepage": "https://github.com/ivandotv/graphql-no-alias#readme", + "dependencies": { + "graphql-no-alias": "../no-alias" + }, + "peerDependencies": { + "@envelop/core": "^1.7.1" + }, + "devDependencies": { + "@babel/core": "^7.16.7", + "@babel/preset-env": "^7.16.7", + "@babel/preset-typescript": "^7.16.7", + "@changesets/cli": "^2.19.0", + "@envelop/core": "^1.7.1", + "@envelop/testing": "^3.0.1", + "@envelop/types": "^1.5.1", + "@types/jest": "^27.4.0", + "@typescript-eslint/eslint-plugin": "^5.8.1", + "@typescript-eslint/parser": "^5.8.1", + "eslint": "^8.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-jest": "^25.3.4", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^6.0.0", + "eslint-plugin-tsdoc": "^0.2.14", + "graphql": "^16.2.0", + "jest": "^27.4.5", + "jest-watch-typeahead": "^1.0.0", + "lint-staged": "^12.1.4", + "microbundle": "^0.14.2", + "prettier": "^2.5.1", + "shx": "^0.3.3", + "typescript": "^4.5.5" + } +} diff --git a/packages/no-alias/package.json b/packages/no-alias/package.json index 99ead70..733c2c1 100644 --- a/packages/no-alias/package.json +++ b/packages/no-alias/package.json @@ -35,7 +35,6 @@ "build:prod": "NODE_ENV=production microbundle --tsconfig ./tsconfig.json --format modern,cjs --target node --output dist/prod", "build": "rm -rf ./dist && pnpm build:prod", "prepublishOnly": "pnpm build", - "prepare": "husky install", "release": "pnpm run prepublishOnly && pnpm changeset publish" }, "repository": { @@ -53,7 +52,6 @@ "@babel/core": "^7.16.7", "@babel/preset-env": "^7.16.7", "@babel/preset-typescript": "^7.16.7", - "@changesets/cli": "^2.19.0", "@types/jest": "^27.4.0", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", @@ -64,13 +62,12 @@ "eslint-plugin-promise": "^6.0.0", "eslint-plugin-tsdoc": "^0.2.14", "graphql": "^16.2.0", - "husky": "^7.0.4", "jest": "^27.4.5", - "jest-mock-console": "^1.2.3", "jest-watch-typeahead": "^1.0.0", "lint-staged": "^12.1.4", "microbundle": "^0.14.2", "prettier": "^2.5.1", - "shx": "^0.3.3" + "shx": "^0.3.3", + "typescript": "^4.5.5" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 31a97bd..46223ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,12 +19,13 @@ importers: del: 6.0.0 minimist: 1.2.5 - packages/no-alias: + packages/envelop: specifiers: '@babel/core': ^7.16.7 '@babel/preset-env': ^7.16.7 '@babel/preset-typescript': ^7.16.7 '@changesets/cli': ^2.19.0 + '@envelop/core': ^1.7.1 '@types/jest': ^27.4.0 '@typescript-eslint/eslint-plugin': ^5.8.1 '@typescript-eslint/parser': ^5.8.1 @@ -35,37 +36,83 @@ importers: eslint-plugin-promise: ^6.0.0 eslint-plugin-tsdoc: ^0.2.14 graphql: ^16.2.0 - husky: ^7.0.4 + graphql-no-alias: ../no-alias jest: ^27.4.5 - jest-mock-console: ^1.2.3 jest-watch-typeahead: ^1.0.0 lint-staged: ^12.1.4 microbundle: ^0.14.2 prettier: ^2.5.1 shx: ^0.3.3 + typescript: ^4.5.5 + dependencies: + graphql-no-alias: link:../no-alias devDependencies: '@babel/core': 7.16.7 '@babel/preset-env': 7.16.7_@babel+core@7.16.7 '@babel/preset-typescript': 7.16.7_@babel+core@7.16.7 '@changesets/cli': 2.19.0 + '@envelop/core': 1.7.1_graphql@16.2.0 '@types/jest': 27.4.0 - '@typescript-eslint/eslint-plugin': 5.8.1_6e71998ecdb938417ab1e2ca4e024f09 - '@typescript-eslint/parser': 5.8.1_eslint@8.6.0 + '@typescript-eslint/eslint-plugin': 5.8.1_f11aee50aaa0e443115d2f7516752d43 + '@typescript-eslint/parser': 5.8.1_eslint@8.6.0+typescript@4.5.5 eslint: 8.6.0 eslint-config-prettier: 8.3.0_eslint@8.6.0 - eslint-plugin-jest: 25.3.4_cac5dc51ed5a5c1ae220309c27c6e099 + eslint-plugin-jest: 25.3.4_b173ff4baaa840056eeb2773d4a34bd3 + eslint-plugin-prettier: 4.0.0_1c588f61426b1faf18812943f1678311 + eslint-plugin-promise: 6.0.0_eslint@8.6.0 + eslint-plugin-tsdoc: 0.2.14 + graphql: 16.2.0 + jest: 27.4.5 + jest-watch-typeahead: 1.0.0_jest@27.4.5 + lint-staged: 12.3.1 + microbundle: 0.14.2 + prettier: 2.5.1 + shx: 0.3.3 + typescript: 4.5.5 + + packages/no-alias: + specifiers: + '@babel/core': ^7.16.7 + '@babel/preset-env': ^7.16.7 + '@babel/preset-typescript': ^7.16.7 + '@types/jest': ^27.4.0 + '@typescript-eslint/eslint-plugin': ^5.8.1 + '@typescript-eslint/parser': ^5.8.1 + eslint: ^8.6.0 + eslint-config-prettier: ^8.3.0 + eslint-plugin-jest: ^25.3.4 + eslint-plugin-prettier: ^4.0.0 + eslint-plugin-promise: ^6.0.0 + eslint-plugin-tsdoc: ^0.2.14 + graphql: ^16.2.0 + jest: ^27.4.5 + jest-watch-typeahead: ^1.0.0 + lint-staged: ^12.1.4 + microbundle: ^0.14.2 + prettier: ^2.5.1 + shx: ^0.3.3 + typescript: ^4.5.5 + devDependencies: + '@babel/core': 7.16.7 + '@babel/preset-env': 7.16.7_@babel+core@7.16.7 + '@babel/preset-typescript': 7.16.7_@babel+core@7.16.7 + '@types/jest': 27.4.0 + '@typescript-eslint/eslint-plugin': 5.8.1_f11aee50aaa0e443115d2f7516752d43 + '@typescript-eslint/parser': 5.8.1_eslint@8.6.0+typescript@4.5.5 + eslint: 8.6.0 + eslint-config-prettier: 8.3.0_eslint@8.6.0 + eslint-plugin-jest: 25.3.4_b173ff4baaa840056eeb2773d4a34bd3 eslint-plugin-prettier: 4.0.0_1c588f61426b1faf18812943f1678311 eslint-plugin-promise: 6.0.0_eslint@8.6.0 eslint-plugin-tsdoc: 0.2.14 graphql: 16.2.0 - husky: 7.0.4 jest: 27.4.5 - jest-mock-console: 1.2.3_jest@27.4.5 jest-watch-typeahead: 1.0.0_jest@27.4.5 lint-staged: 12.1.4 microbundle: 0.14.2 prettier: 2.5.1 shx: 0.3.3 + typescript: 4.5.5 packages: @@ -1540,6 +1587,23 @@ packages: prettier: 1.19.1 dev: true + /@envelop/core/1.7.1_graphql@16.2.0: + resolution: {integrity: sha512-ZxeQs4G0FOzoFAH+zskubx5aM9kx6BiUvcSI9Lo3MfYBmnK7cjwcwDdwk6Mq48QDuAeVdGfDmQz+BiWg0k2GmQ==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 + dependencies: + '@envelop/types': 1.5.1_graphql@16.2.0 + graphql: 16.2.0 + dev: true + + /@envelop/types/1.5.1_graphql@16.2.0: + resolution: {integrity: sha512-NrwLVzyNqiSzgRRqOxkU2IgRc5hSGS73VsgxqchU3jl36rYo7AXVAnITkytmB9wk+jN2vUOVvayLkaTXooARwg==} + peerDependencies: + graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 + dependencies: + graphql: 16.2.0 + dev: true + /@eslint/eslintrc/1.0.5: resolution: {integrity: sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -2067,7 +2131,7 @@ packages: '@types/yargs-parser': 20.2.1 dev: true - /@typescript-eslint/eslint-plugin/5.8.1_6e71998ecdb938417ab1e2ca4e024f09: + /@typescript-eslint/eslint-plugin/5.8.1_f11aee50aaa0e443115d2f7516752d43: resolution: {integrity: sha512-wTZ5oEKrKj/8/366qTM366zqhIKAp6NCMweoRONtfuC07OAU9nVI2GZZdqQ1qD30WAAtcPdkH+npDwtRFdp4Rw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2078,8 +2142,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 5.8.1_eslint@8.6.0 - '@typescript-eslint/parser': 5.8.1_eslint@8.6.0 + '@typescript-eslint/experimental-utils': 5.8.1_eslint@8.6.0+typescript@4.5.5 + '@typescript-eslint/parser': 5.8.1_eslint@8.6.0+typescript@4.5.5 '@typescript-eslint/scope-manager': 5.8.1 debug: 4.3.3 eslint: 8.6.0 @@ -2087,12 +2151,13 @@ packages: ignore: 5.2.0 regexpp: 3.2.0 semver: 7.3.5 - tsutils: 3.21.0 + tsutils: 3.21.0_typescript@4.5.5 + typescript: 4.5.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/experimental-utils/5.8.1_eslint@8.6.0: + /@typescript-eslint/experimental-utils/5.8.1_eslint@8.6.0+typescript@4.5.5: resolution: {integrity: sha512-fbodVnjIDU4JpeXWRDsG5IfIjYBxEvs8EBO8W1+YVdtrc2B9ppfof5sZhVEDOtgTfFHnYQJDI8+qdqLYO4ceww==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2101,7 +2166,7 @@ packages: '@types/json-schema': 7.0.9 '@typescript-eslint/scope-manager': 5.8.1 '@typescript-eslint/types': 5.8.1 - '@typescript-eslint/typescript-estree': 5.8.1 + '@typescript-eslint/typescript-estree': 5.8.1_typescript@4.5.5 eslint: 8.6.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.6.0 @@ -2110,7 +2175,7 @@ packages: - typescript dev: true - /@typescript-eslint/parser/5.8.1_eslint@8.6.0: + /@typescript-eslint/parser/5.8.1_eslint@8.6.0+typescript@4.5.5: resolution: {integrity: sha512-K1giKHAjHuyB421SoXMXFHHVI4NdNY603uKw92++D3qyxSeYvC10CBJ/GE5Thpo4WTUvu1mmJI2/FFkz38F2Gw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2122,9 +2187,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.8.1 '@typescript-eslint/types': 5.8.1 - '@typescript-eslint/typescript-estree': 5.8.1 + '@typescript-eslint/typescript-estree': 5.8.1_typescript@4.5.5 debug: 4.3.3 eslint: 8.6.0 + typescript: 4.5.5 transitivePeerDependencies: - supports-color dev: true @@ -2142,7 +2208,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree/5.8.1: + /@typescript-eslint/typescript-estree/5.8.1_typescript@4.5.5: resolution: {integrity: sha512-26lQ8l8tTbG7ri7xEcCFT9ijU5Fk+sx/KRRyyzCv7MQ+rZZlqiDPtMKWLC8P7o+dtCnby4c+OlxuX1tp8WfafQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2157,7 +2223,8 @@ packages: globby: 11.0.4 is-glob: 4.0.3 semver: 7.3.5 - tsutils: 3.21.0 + tsutils: 3.21.0_typescript@4.5.5 + typescript: 4.5.5 transitivePeerDependencies: - supports-color dev: true @@ -3270,7 +3337,7 @@ packages: eslint: 8.6.0 dev: true - /eslint-plugin-jest/25.3.4_cac5dc51ed5a5c1ae220309c27c6e099: + /eslint-plugin-jest/25.3.4_b173ff4baaa840056eeb2773d4a34bd3: resolution: {integrity: sha512-CCnwG71wvabmwq/qkz0HWIqBHQxw6pXB1uqt24dxqJ9WB34pVg49bL1sjXphlJHgTMWGhBjN1PicdyxDxrfP5A==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} peerDependencies: @@ -3283,8 +3350,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.8.1_6e71998ecdb938417ab1e2ca4e024f09 - '@typescript-eslint/experimental-utils': 5.8.1_eslint@8.6.0 + '@typescript-eslint/eslint-plugin': 5.8.1_f11aee50aaa0e443115d2f7516752d43 + '@typescript-eslint/experimental-utils': 5.8.1_eslint@8.6.0+typescript@4.5.5 eslint: 8.6.0 jest: 27.4.5 transitivePeerDependencies: @@ -3914,6 +3981,7 @@ packages: resolution: {integrity: sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==} engines: {node: '>=12'} hasBin: true + dev: false /iconv-lite/0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} @@ -4502,14 +4570,6 @@ packages: stack-utils: 2.0.5 dev: true - /jest-mock-console/1.2.3_jest@27.4.5: - resolution: {integrity: sha512-q4jfuHW3V3tYzwtKTF6nxjRNriUC2/D2SVfxW88lNeG1qO1mVarBUqgOAvZjTEmxuTsjzGlHQsDIgvlOZaLccg==} - peerDependencies: - jest: '>= 22.4.2' - dependencies: - jest: 27.4.5 - dev: true - /jest-mock/27.4.2: resolution: {integrity: sha512-PDDPuyhoukk20JrQKeofK12hqtSka7mWH0QQuxSNgrdiPsrnYYLS6wbzu/HDlxZRzji5ylLRULeuI/vmZZDrYA==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} @@ -4949,7 +5009,6 @@ packages: yaml: 1.10.2 transitivePeerDependencies: - enquirer - dev: false /listr2/3.13.5: resolution: {integrity: sha512-3n8heFQDSk+NcwBn3CgxEibZGaRzx+pC64n3YjpMD1qguV4nWus3Al+Oo3KooqFKTQEJ1v7MmnbnyyNspgx3NA==} @@ -4987,7 +5046,6 @@ packages: rxjs: 7.5.2 through: 2.3.8 wrap-ansi: 7.0.0 - dev: false /load-yaml-file/0.2.0: resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==} @@ -5176,12 +5234,12 @@ packages: rollup-plugin-bundle-size: 1.0.3 rollup-plugin-postcss: 4.0.2_postcss@8.4.5 rollup-plugin-terser: 7.0.2_rollup@2.62.0 - rollup-plugin-typescript2: 0.29.0_rollup@2.62.0+typescript@4.5.4 + rollup-plugin-typescript2: 0.29.0_rollup@2.62.0+typescript@4.5.5 sade: 1.8.0 terser: 5.10.0 tiny-glob: 0.2.9 tslib: 2.3.1 - typescript: 4.5.4 + typescript: 4.5.5 transitivePeerDependencies: - '@types/babel__core' - acorn @@ -6244,7 +6302,7 @@ packages: - acorn dev: true - /rollup-plugin-typescript2/0.29.0_rollup@2.62.0+typescript@4.5.4: + /rollup-plugin-typescript2/0.29.0_rollup@2.62.0+typescript@4.5.5: resolution: {integrity: sha512-YytahBSZCIjn/elFugEGQR5qTsVhxhUwGZIsA9TmrSsC88qroGo65O5HZP/TTArH2dm0vUmYWhKchhwi2wL9bw==} peerDependencies: rollup: '>=1.26.3' @@ -6256,7 +6314,7 @@ packages: resolve: 1.17.0 rollup: 2.62.0 tslib: 2.0.1 - typescript: 4.5.4 + typescript: 4.5.5 dev: true /rollup-pluginutils/2.8.2: @@ -6852,13 +6910,14 @@ packages: /tslib/2.3.1: resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==} - /tsutils/3.21.0: + /tsutils/3.21.0_typescript@4.5.5: resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 + typescript: 4.5.5 dev: true /tty-table/2.8.13: @@ -6923,8 +6982,8 @@ packages: is-typedarray: 1.0.0 dev: true - /typescript/4.5.4: - resolution: {integrity: sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==} + /typescript/4.5.5: + resolution: {integrity: sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==} engines: {node: '>=4.2.0'} hasBin: true dev: true From f9177d401fc51ef0985cd66a5b1cc66d297506d3 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Mon, 24 Jan 2022 21:43:07 +0100 Subject: [PATCH 5/7] add envelop plugin --- packages/envelop/README.md | 23 ++++ packages/envelop/package.json | 4 +- packages/envelop/src/__tests__/plugin.test.ts | 115 ++++++++++++++++++ packages/envelop/src/index.ts | 14 +++ .../no-alias/src/__tests__/directive.test.ts | 2 +- 5 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 packages/envelop/README.md create mode 100644 packages/envelop/src/__tests__/plugin.test.ts create mode 100644 packages/envelop/src/index.ts diff --git a/packages/envelop/README.md b/packages/envelop/README.md new file mode 100644 index 0000000..cc73eca --- /dev/null +++ b/packages/envelop/README.md @@ -0,0 +1,23 @@ +# Envelop Plugin + +This package is an [envelop plugin](https://www.envelop.dev) version of +[`graphql-no-alias`](https://github.com/ivandotv/graphql-no-alias) validation directive. + +## Install + +```sh +npm Install envelop-no-alias +``` + +## Usage + +```ts +import { envelop } from '@envelop/core' +import { useNoAlias, NoAliasConfig } from 'envelop-no-alias' + +//optional configuration +const config: NoAliasConfig = {} +const getEnveloped = envelop({ + plugins: [useNoAlias(config)] +}) +``` diff --git a/packages/envelop/package.json b/packages/envelop/package.json index 8cb69f3..92d8f23 100644 --- a/packages/envelop/package.json +++ b/packages/envelop/package.json @@ -1,8 +1,8 @@ { "name": "envelop-no-alias", - "version": "1.0.1", + "version": "1.0.0", "private": false, - "description": "Graphql envelop plugin for no alias directive for graphql mutation and query types. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", + "description": "Graphql envelop plugin for no alias graphql directive. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", "keywords": [ "@envelop", "envelop", diff --git a/packages/envelop/src/__tests__/plugin.test.ts b/packages/envelop/src/__tests__/plugin.test.ts new file mode 100644 index 0000000..faaf313 --- /dev/null +++ b/packages/envelop/src/__tests__/plugin.test.ts @@ -0,0 +1,115 @@ +import { assertSingleExecutionValue, createTestkit } from '@envelop/testing' +import { buildSchema } from 'graphql' +import createValidation from 'graphql-no-alias' +import { useNoAlias } from '../' + +describe('No Alias plugin', () => { + test('If the directive is not used, it does not fail', async () => { + const { typeDefs } = createValidation() + const schema = buildSchema(/* GraphQL */ ` + ${typeDefs} + + type Query { + getUser: User + } + type User { + name: String + } + `) + + const query = /* GraphQL */ ` + { + getUser { + name + } + alias_1: getUser { + name + } + } + ` + const testkit = createTestkit([useNoAlias()], schema) + const result = await testkit.execute(query) + assertSingleExecutionValue(result) + expect(result.data).toBeDefined() + }) + + test('Do not allow double query', async () => { + const { typeDefs } = createValidation() + const defaultAllow = 1 + const schema = buildSchema(/* GraphQL */ ` + ${typeDefs} + + type Query { + getUser: User @noAlias + } + type User { + name: String + } + `) + + const query = /* GraphQL */ ` + { + getUser { + name + } + alias_1: getUser { + name + } + } + ` + const testkit = createTestkit([useNoAlias()], schema) + const result = await testkit.execute(query) + assertSingleExecutionValue(result) + expect(result.data).toBeUndefined() + + expect(result.errors).toHaveLength(1) + expect(result.errors[0].message).toMatch( + new RegExp(`Allowed number of calls.+${defaultAllow}`, 'i') + ) + }) + + test('Correctly pass in configuration object', async () => { + const defaultAllow = 1 + const permissions = { + Query: { + '*': defaultAllow + } + } + const schema = buildSchema(/* GraphQL */ ` + type Query { + getUser: User + getAnotherUser: User + } + type User { + name: String + } + `) + + const query = /* GraphQL */ ` + { + getUser { + name + } + alias_1: getUser { + name + } + getAnotherUser { + name + } + alias_2: getAnotherUser { + name + } + } + ` + + const testkit = createTestkit([useNoAlias({ permissions })], schema) + const result = await testkit.execute(query) + assertSingleExecutionValue(result) + expect(result.data).toBeUndefined() + + expect(result.errors).toHaveLength(2) + expect(result.errors[0].message).toMatch( + new RegExp(`Allowed number of calls.+${defaultAllow}`, 'i') + ) + }) +}) diff --git a/packages/envelop/src/index.ts b/packages/envelop/src/index.ts new file mode 100644 index 0000000..97d47d7 --- /dev/null +++ b/packages/envelop/src/index.ts @@ -0,0 +1,14 @@ +import { Plugin } from '@envelop/types' +import createValidation, { Config } from 'graphql-no-alias' + +export type NoAliasConfig = Config + +export function useNoAlias(config?: Config): Plugin { + const { validation } = createValidation(config) + + return { + onValidate({ addValidationRule }) { + addValidationRule(validation) + } + } +} diff --git a/packages/no-alias/src/__tests__/directive.test.ts b/packages/no-alias/src/__tests__/directive.test.ts index 008cad0..f9ea6b4 100644 --- a/packages/no-alias/src/__tests__/directive.test.ts +++ b/packages/no-alias/src/__tests__/directive.test.ts @@ -48,7 +48,7 @@ describe('Directive on type field', () => { const query = /* GraphQL */ ` { - getUser @noAlias { + getUser { name } alias_1: getUser { From 0c257d41c433f2986ae21c24fabf29e319065c24 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Mon, 24 Jan 2022 22:07:12 +0100 Subject: [PATCH 6/7] update readme --- README.md | 26 +++++++++++++++++++++++--- codecov.yml | 8 ++++++++ packages/envelop/tsconfig.json | 29 +++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 packages/envelop/tsconfig.json diff --git a/README.md b/README.md index f90b8fe..aabdc3e 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,26 @@ ![Codecov](https://img.shields.io/codecov/c/gh/ivandotv/graphql-no-alias) [![GitHub license](https://img.shields.io/github/license/ivandotv/graphql-no-alias)](https://github.com/ivandotv/graphql-no-alias/blob/main/LICENSE) -Graphql validation with accompanying directive to limit the number of `alias` queries and mutations you can use. -It effectively disables batching of queries and mutations. + -## Why +- [Inspiration](#inspiration) +- [Instalation](#instalation) +- [Usage](#usage) + - [Using the directive](#using-the-directive) + - [Schema setup](#schema-setup) + - [Object type](#object-type) + - [Field type](#field-type) + - [Customizing the declaration](#customizing-the-declaration) + - [Imperative configuration](#imperative-configuration) + - [Customizing the error message](#customizing-the-error-message) +- [Envelop Plugin](#envelop-plugin) + - [License](#license) + + + +## Inspiration + +Graphql validation with accompanying directive to limit the number of `alias` queries and mutations that can be sent to the GraphQL server. It will disable certain kinds of attacks that look like this. @@ -239,6 +255,10 @@ const { typeDefs, validation } = createValidation({errorFn:( }) ``` +## Envelop Plugin + +If you are using [GraphQL Envelop](https://www.envelop.dev/). I have made a (plugin)[packages/envelop/README.md] that uses this directive. + ### License This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details diff --git a/codecov.yml b/codecov.yml index 0d6d8f9..864fb35 100644 --- a/codecov.yml +++ b/codecov.yml @@ -7,6 +7,10 @@ coverage: target: auto flags: - graphql-no-alias + envelop: + target: auto + flags: + - envelop comment: layout: 'reach, diff, flags, files' @@ -20,3 +24,7 @@ flags: paths: - packages/graphql-no-alias/ carryforward: true + envelop: + paths: + - packages/envelop/ + carryforward: true diff --git a/packages/envelop/tsconfig.json b/packages/envelop/tsconfig.json new file mode 100644 index 0000000..d2370a9 --- /dev/null +++ b/packages/envelop/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + // "lib": ["ESNext"], + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "stripInternal": true, + "esModuleInterop": true, + "skipDefaultLibCheck": false, + "skipLibCheck": false, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "isolatedModules": true, + "incremental": true, + "jsx": "preserve" + }, + "include": ["packages/no-alias/src/**/*"], + "exclude": [ + "**/node_modules", + "packages/no-alias/src/**/__tests__", + "packages/no-alias/src/**/*.test.ts", + "packages/no-alias/src/**/*.spec.ts" + ] +} From f769837b94044452ffabb428fc54e214061fe614 Mon Sep 17 00:00:00 2001 From: ivandotv <390700+ivandotv@users.noreply.github.com> Date: Mon, 24 Jan 2022 22:24:20 +0100 Subject: [PATCH 7/7] fix jest code coverage --- .changeset/few-rings-invite.md | 8 ++++++++ packages/envelop/jest.config.js | 1 - packages/envelop/package.json | 2 +- packages/no-alias/jest.config.js | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/few-rings-invite.md diff --git a/.changeset/few-rings-invite.md b/.changeset/few-rings-invite.md new file mode 100644 index 0000000..fb14062 --- /dev/null +++ b/.changeset/few-rings-invite.md @@ -0,0 +1,8 @@ +--- +'envelop-no-alias': major +'graphql-no-alias': patch +--- + +Initial publish of `envelop-no-alias` + +Update readme for: `graphql-no-alias` diff --git a/packages/envelop/jest.config.js b/packages/envelop/jest.config.js index 6f3d55f..6b2229d 100644 --- a/packages/envelop/jest.config.js +++ b/packages/envelop/jest.config.js @@ -8,7 +8,6 @@ module.exports = { testMatch: ['/src/__tests__/?(*.)+(spec|test).[jt]s?(x)'], collectCoverageFrom: [ '/src/**', - '!/src/index.ts', '!/src/__tests__/**', '!/src/__fixtures__/**' ] diff --git a/packages/envelop/package.json b/packages/envelop/package.json index 92d8f23..c11c08a 100644 --- a/packages/envelop/package.json +++ b/packages/envelop/package.json @@ -1,6 +1,6 @@ { "name": "envelop-no-alias", - "version": "1.0.0", + "version": "0.0.0", "private": false, "description": "Graphql envelop plugin for no alias graphql directive. It can limit the amount of alias fields that can be used for queries and mutations. Preventing batch attacks.", "keywords": [ diff --git a/packages/no-alias/jest.config.js b/packages/no-alias/jest.config.js index 6f3d55f..6b2229d 100644 --- a/packages/no-alias/jest.config.js +++ b/packages/no-alias/jest.config.js @@ -8,7 +8,6 @@ module.exports = { testMatch: ['/src/__tests__/?(*.)+(spec|test).[jt]s?(x)'], collectCoverageFrom: [ '/src/**', - '!/src/index.ts', '!/src/__tests__/**', '!/src/__fixtures__/**' ]