File tree
Expand file treeCollapse file tree7 files changed
+143
-64
lines changed Expand file treeCollapse file tree7 files changed
+143
-64
lines changed This file was deleted.
Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | +push: |
| 5 | +branches: |
| 6 | +- master |
| 7 | +pull_request: |
| 8 | +branches: |
| 9 | +- master |
| 10 | + |
| 11 | +jobs: |
| 12 | +test-and-build: |
| 13 | +runs-on: ubuntu-latest |
| 14 | +strategy: |
| 15 | +matrix: |
| 16 | +graphql-version: ['~15.0', '~16.0'] |
| 17 | +steps: |
| 18 | +- name: Checkout repository |
| 19 | +uses: actions/checkout@v2 |
| 20 | + |
| 21 | +- name: Set up Node.js |
| 22 | +uses: actions/setup-node@v4 |
| 23 | +with: |
| 24 | +node-version: 'latest' |
| 25 | + |
| 26 | +- name: Restore cache |
| 27 | +uses: actions/cache@v2 |
| 28 | +with: |
| 29 | +path: node_modules |
| 30 | +key: v1-dependencies-${{ hashFiles('package.json') }}-${{ matrix.graphql-version }} |
| 31 | +restore-keys: | |
| 32 | +v1-dependencies- |
| 33 | +
|
| 34 | + - name: Install dependencies |
| 35 | +if: matrix.graphql-version != '' |
| 36 | +run: yarn install --ignore-scripts |
| 37 | + |
| 38 | +- name: Add specific graphql version |
| 39 | +if: matrix.graphql-version != '' |
| 40 | +run: yarn --ignore-scripts add --dev graphql@${{ matrix.graphql-version }} |
| 41 | + |
| 42 | +- name: Install dependencies with frozen lockfile |
| 43 | +if: matrix.graphql-version == '' |
| 44 | +run: yarn install --frozen-lockfile |
| 45 | + |
| 46 | +- name: Save cache |
| 47 | +uses: actions/cache@v2 |
| 48 | +with: |
| 49 | +path: node_modules |
| 50 | +key: v1-dependencies-${{ hashFiles('package.json') }}-${{ matrix.graphql-version }} |
| 51 | + |
| 52 | +- name: Run tests |
| 53 | +run: yarn test |
| 54 | + |
| 55 | +test-and-build-with-typecheck: |
| 56 | +runs-on: ubuntu-latest |
| 57 | +steps: |
| 58 | +- name: Checkout repository |
| 59 | +uses: actions/checkout@v2 |
| 60 | + |
| 61 | +- name: Set up Node.js |
| 62 | +uses: actions/setup-node@v4 |
| 63 | +with: |
| 64 | +node-version: 'latest' |
| 65 | + |
| 66 | +- name: Restore cache |
| 67 | +uses: actions/cache@v2 |
| 68 | +with: |
| 69 | +path: node_modules |
| 70 | +key: v1-dependencies-${{ hashFiles('package.json') }} |
| 71 | +restore-keys: | |
| 72 | +v1-dependencies- |
| 73 | +
|
| 74 | + - name: Install dependencies |
| 75 | +run: yarn install --frozen-lockfile |
| 76 | + |
| 77 | +- name: Save cache |
| 78 | +uses: actions/cache@v2 |
| 79 | +with: |
| 80 | +path: node_modules |
| 81 | +key: v1-dependencies-${{ hashFiles('package.json') }} |
| 82 | + |
| 83 | +- name: Run tests |
| 84 | +run: yarn test |
Original file line number | Diff line number | Diff line change |
---|
|
2 | 2 |
|
3 | 3 | [](https://www.npmjs.com/package/graphql-query-complexity)
|
4 | 4 | [](https://badge.fury.io/js/graphql-query-complexity)
|
5 |
| -[](https://circleci.com/gh/slicknode/graphql-query-complexity) |
6 | 5 | [](https://twitter.com/slicknode)
|
7 | 6 |
|
8 | 7 | This library provides GraphQL query analysis to reject complex queries to your GraphQL server.
|
|
Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Create package.json for CommonJS |
1 | 4 | cat >dist/cjs/package.json <<!EOF
|
2 | 5 | {
|
3 | 6 | "type": "commonjs"
|
4 | 7 | }
|
5 | 8 | !EOF
|
6 | 9 |
|
| 10 | +# Define the file paths |
| 11 | +cjs_file_path="dist/cjs/QueryComplexity.js" |
| 12 | +esm_file_path="dist/esm/QueryComplexity.js" |
| 13 | +find_path="dist/esm" |
| 14 | + |
| 15 | +# Detect the operating system and use the appropriate sed command |
| 16 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 17 | +# macOS (BSD sed) |
| 18 | +sed -i '' 's/require("graphql\/execution\/values")/require("graphql\/execution\/values.js")/' "$cjs_file_path" |
| 19 | +else |
| 20 | +# Linux (GNU sed) |
| 21 | +sed -i 's/require("graphql\/execution\/values")/require("graphql\/execution\/values.js")/' "$cjs_file_path" |
| 22 | +fi |
| 23 | + |
| 24 | +# Create package.json for ES modules |
7 | 25 | cat >dist/esm/package.json <<!EOF
|
8 | 26 | {
|
9 | 27 | "type": "module"
|
10 | 28 | }
|
11 | 29 | !EOF
|
| 30 | + |
| 31 | +# Detect the operating system and use the appropriate sed command |
| 32 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 33 | +# macOS (BSD sed) |
| 34 | +sed -i '' 's/from '\''graphql\/execution\/values'\'';/from '\''graphql\/execution\/values.mjs'\'';/' "$esm_file_path" |
| 35 | +find "$find_path" -type f -name "*.js" -exec sed -i '' 's/from '\''graphql'\'';/from '\''graphql\/index.mjs'\'';/' {} + |
| 36 | +else |
| 37 | +# Linux (GNU sed) |
| 38 | +sed -i 's/from '\''graphql\/execution\/values'\'';/from '\''graphql\/execution\/values.mjs'\'';/' "$esm_file_path" |
| 39 | +find "$find_path" -type f -name "*.js" -exec sed -i 's/from '\''graphql'\'';/from '\''graphql\/index.mjs'\'';/' {} + |
| 40 | +fi |
Original file line number | Diff line number | Diff line change |
---|
@@ -2,4 +2,14 @@ cat >dist/test/cjs/package.json <<!EOF
|
2 | 2 | {
|
3 | 3 | "type": "commonjs"
|
4 | 4 | }
|
5 |
| -!EOF |
| 5 | +!EOF |
| 6 | + |
| 7 | +file_path="dist/test/cjs/QueryComplexity.js" |
| 8 | + |
| 9 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 10 | +# macOS (BSD sed) |
| 11 | +sed -i '' 's/require("graphql\/execution\/values")/require("graphql\/execution\/values.js")/' "$file_path" |
| 12 | +else |
| 13 | +# Linux (GNU sed) |
| 14 | +sed -i 's/require("graphql\/execution\/values")/require("graphql\/execution\/values.js")/' "$file_path" |
| 15 | +fi |
Original file line number | Diff line number | Diff line change |
---|
@@ -3,3 +3,17 @@ cat >dist/test/esm/package.json <<!EOF
|
3 | 3 | "type": "module"
|
4 | 4 | }
|
5 | 5 | !EOF
|
| 6 | + |
| 7 | +file_path="dist/test/esm/QueryComplexity.js" |
| 8 | +find_path="dist/test/esm" |
| 9 | + |
| 10 | +# Detect the operating system and use the appropriate sed command |
| 11 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 12 | +# macOS (BSD sed) |
| 13 | +sed -i '' 's/from '\''graphql\/execution\/values'\'';/from '\''graphql\/execution\/values.mjs'\'';/' "$file_path" |
| 14 | +find "$find_path" -type f -name "*.js" -exec sed -i '' 's/from '\''graphql'\'';/from '\''graphql\/index.mjs'\'';/' {} + |
| 15 | +else |
| 16 | +# Linux (GNU sed) |
| 17 | +sed -i 's/from '\''graphql\/execution\/values'\'';/from '\''graphql\/execution\/values.mjs'\'';/' "$file_path" |
| 18 | +find "$find_path" -type f -name "*.js" -exec sed -i 's/from '\''graphql'\'';/from '\''graphql\/index.mjs'\'';/' {} + |
| 19 | +fi |
Original file line number | Diff line number | Diff line change |
---|
|
16 | 16 | "build:test:esm": "tsc -p ./tsconfig.test.esm.json && ./fix-hybrid-module.test.esm.sh",
|
17 | 17 | "test": "npm run lint && npm run build:test:cjs && npm run testonly:cjs && npm run build:test:esm && npm run testonly:esm",
|
18 | 18 | "testonly:cjs": "mocha --check-s --exit --full-trace 'dist/test/cjs/**/__tests__/**/*-test.js'",
|
19 |
| -"testonly:esm": "mocha -n experimental-json-modules --check-s --exit --full-trace 'dist/test/esm/**/__tests__/**/*-test.js'", |
| 19 | +"testonly:esm": "mocha -n experimental-json-modules --loader=ts-node/esm --check-s --exit --full-trace 'dist/test/esm/**/__tests__/**/*-test.js'", |
20 | 20 | "dist": "npm run clean && npm run build",
|
21 | 21 | "prepare": "npm run clean && npm run dist"
|
22 | 22 | },
|
|
27 | 27 | "lodash.get": "^4.4.2"
|
28 | 28 | },
|
29 | 29 | "peerDependencies": {
|
30 |
| -"graphql": "^14.6.0 || ^15.0.0 || ^16.0.0" |
| 30 | +"graphql": "^15.0.0 || ^16.0.0" |
31 | 31 | },
|
32 | 32 | "files": [
|
33 | 33 | "dist",
|
|
47 | 47 | ".": {
|
48 | 48 | "import": "./dist/esm/index.js",
|
49 | 49 | "require": "./dist/cjs/index.js"
|
50 |
| -} |
| 50 | +}, |
| 51 | +"./esm": "./dist/esm/index.js", |
| 52 | +"./cjs": "./dist/cjs/index.js" |
51 | 53 | },
|
52 | 54 | "author": "Ivo Meißner",
|
53 | 55 | "license": "MIT",
|
|
You can’t perform that action at this time.
0 commit comments