From 5d8471e20a4e132c639b4c30a2d6427d854ddae3 Mon Sep 17 00:00:00 2001 From: Pieter Van der Haegen Date: Fri, 26 Nov 2021 16:27:00 +0100 Subject: [PATCH 1/2] feat: allow graphql@16 as peer dependency --- package.json | 6 +- yarn.lock | 152 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 99 insertions(+), 59 deletions(-) diff --git a/package.json b/package.json index 4d08db925..137e8335b 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "form-data": "^3.0.0" }, "peerDependencies": { - "graphql": "14.x || 15.x" + "graphql": "14 - 16" }, "devDependencies": { "@prisma-labs/prettier-config": "^0.1.0", @@ -58,14 +58,14 @@ "@types/graphql-upload": "^8.0.6", "@types/jest": "^26.0.24", "@types/node": "^16.4.3", - "apollo-server-express": "^3.0.2", + "apollo-server-express": "^3.5.0", "body-parser": "^1.19.0", "doctoc": "^2.0.1", "dripip": "^0.10.0", "express": "^4.17.1", "fetch-cookie": "^1.0.0", "get-port": "^5.1.1", - "graphql": "^15.5.1", + "graphql": "16", "graphql-tag": "^2.12.5", "graphql-upload": "^12.0.0", "jest": "^27.0.6", diff --git a/yarn.lock b/yarn.lock index c7705b2c8..59e06c1ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -340,6 +340,14 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@graphql-tools/merge@^8.2.1": + version "8.2.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/merge/-/merge-8.2.1.tgz#bf83aa06a0cfc6a839e52a58057a84498d0d51ff" + integrity sha512-Q240kcUszhXiAYudjuJgNuLgy9CryDP3wp83NOZQezfA6h3ByYKU7xI6DiKrdjyVaGpYN3ppUmdj0uf5GaXzMA== + dependencies: + "@graphql-tools/utils" "^8.5.1" + tslib "~2.3.0" + "@graphql-tools/mock@^8.1.2": version "8.1.3" resolved "https://registry.yarnpkg.com/@graphql-tools/mock/-/mock-8.1.3.tgz#bad4aa7a6ce3e37739e2df9a86ac3925bfde15b2" @@ -351,7 +359,7 @@ ts-is-defined "^1.0.0" tslib "~2.2.0" -"@graphql-tools/schema@^7.0.0", "@graphql-tools/schema@^7.1.5": +"@graphql-tools/schema@^7.0.0": version "7.1.5" resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-7.1.5.tgz#07b24e52b182e736a6b77c829fc48b84d89aa711" integrity sha512-uyn3HSNSckf4mvQSq0Q07CPaVZMNFCYEVxroApOaw802m9DcZPgf9XVPy/gda5GWj9AhbijfRYVTZQgHnJ4CXA== @@ -360,7 +368,17 @@ tslib "~2.2.0" value-or-promise "1.0.6" -"@graphql-tools/utils@^7.0.0", "@graphql-tools/utils@^7.1.2", "@graphql-tools/utils@^7.9.0": +"@graphql-tools/schema@^8.0.0": + version "8.3.1" + resolved "https://registry.yarnpkg.com/@graphql-tools/schema/-/schema-8.3.1.tgz#1ee9da494d2da457643b3c93502b94c3c4b68c74" + integrity sha512-3R0AJFe715p4GwF067G5i0KCr/XIdvSfDLvTLEiTDQ8V/hwbOHEKHKWlEBHGRQwkG5lwFQlW1aOn7VnlPERnWQ== + dependencies: + "@graphql-tools/merge" "^8.2.1" + "@graphql-tools/utils" "^8.5.1" + tslib "~2.3.0" + value-or-promise "1.0.11" + +"@graphql-tools/utils@^7.0.0", "@graphql-tools/utils@^7.1.2": version "7.10.0" resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-7.10.0.tgz#07a4cb5d1bec1ff1dc1d47a935919ee6abd38699" integrity sha512-d334r6bo9mxdSqZW6zWboEnnOOFRrAPVQJ7LkU8/6grglrbcu6WhwCLzHb90E94JI3TD3ricC3YGbUqIi9Xg0w== @@ -369,6 +387,13 @@ camel-case "4.1.2" tslib "~2.2.0" +"@graphql-tools/utils@^8.0.0", "@graphql-tools/utils@^8.5.1": + version "8.5.3" + resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.5.3.tgz#404062e62cae9453501197039687749c4885356e" + integrity sha512-HDNGWFVa8QQkoQB0H1lftvaO1X5xUaUDk1zr1qDe0xN1NL0E/CrQdJ5UKLqOvH4hkqVUPxQsyOoAZFkaH6rLHg== + dependencies: + tslib "~2.3.0" + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -1246,13 +1271,13 @@ anymatch@^3.0.3: normalize-path "^3.0.0" picomatch "^2.0.4" -apollo-datasource@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-3.0.2.tgz#5602ded79657d9ffd0e150c4f9ca472753830200" - integrity sha512-pZ7RDW2UVxxgSovshM27OHQ+rPlDjvGWdAQux6WswJrYEDx8sbJOr39GuyUBVL6yvNuIloOY6rsoG0NRqZ5mbQ== +apollo-datasource@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/apollo-datasource/-/apollo-datasource-3.3.0.tgz#ee84a802c45818e6a21a5f2d427f94851a4f9ebe" + integrity sha512-It8POTZTOCAnedRj2izEVeySN06LIfojigZjWaOY7voLe0DIgtvhql91xr27fuIWsR/Ew9twO3dLBjjvy34J4Q== dependencies: - apollo-server-caching "^3.0.1" - apollo-server-env "^4.0.2" + apollo-server-caching "^3.3.0" + apollo-server-env "^4.2.0" apollo-graphql@^0.9.0: version "0.9.3" @@ -1263,39 +1288,39 @@ apollo-graphql@^0.9.0: lodash.sortby "^4.7.0" sha.js "^2.4.11" -apollo-reporting-protobuf@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/apollo-reporting-protobuf/-/apollo-reporting-protobuf-3.0.0.tgz#a53966b76a3f373d9336bc953f0bc6dede487270" - integrity sha512-jmCD+6gECt8KS7PxP460hztT/5URTbv2Kg0zgnR6iWPGce88IBmSUjcqf1Z6wJJq7Teb8Hu7WbyyMhn0vN5TxQ== +apollo-reporting-protobuf@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/apollo-reporting-protobuf/-/apollo-reporting-protobuf-3.2.0.tgz#6735231e0d77a242708ec3712eaa1ee211d2f974" + integrity sha512-2v/5IRJeTGakCJo8kS2LeKUcLsgqxO/HpEyu1EaW79F0CsvrIk10tOIGxouoOgtVl5e1wfGePJ849CUWWczx2A== dependencies: "@apollo/protobufjs" "1.2.2" -apollo-server-caching@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-3.0.1.tgz#bb6e51442266cb3ff05611c24c4e2f2fe8d6949e" - integrity sha512-Cd0imFQlU6IKrkm+RNY0MQvKTMBTME+518EuwCaw3TKNUYDpir1vOuIdc4bALXDANilOR73k/UQs/oPxayXfrg== +apollo-server-caching@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/apollo-server-caching/-/apollo-server-caching-3.3.0.tgz#f501cbeb820a4201d98c2b768c085f22848d9dc5" + integrity sha512-Wgcb0ArjZ5DjQ7ID+tvxUcZ7Yxdbk5l1MxZL8D8gkyjooOkhPNzjRVQ7ubPoXqO54PrOMOTm1ejVhsF+AfIirQ== dependencies: lru-cache "^6.0.0" -apollo-server-core@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-3.0.2.tgz#bc8316bf6ef2a4d5c0a9d7b6af347085230a6941" - integrity sha512-CDphrxAZdx1yt4CzVMKq5NOsaAKFzVnPBWzzL5Vi/BUTenCjqaVcRHxAVbjFEQJJv+Hv+RpEru51sLRjbJtRUQ== +apollo-server-core@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/apollo-server-core/-/apollo-server-core-3.5.0.tgz#09d05554e6aed9fed296d7bff99e2b8ca31f49eb" + integrity sha512-c3wEnPSnzvWvYvRJq1B+yIpa+vBvm0kq0tvD4j/IOw/F1s3sadu43Xr4FiLw++UfeLyh3aS5Wk68hjvrW1ceiQ== dependencies: "@apollographql/apollo-tools" "^0.5.1" "@apollographql/graphql-playground-html" "1.6.29" "@graphql-tools/mock" "^8.1.2" - "@graphql-tools/schema" "^7.1.5" - "@graphql-tools/utils" "^7.9.0" + "@graphql-tools/schema" "^8.0.0" + "@graphql-tools/utils" "^8.0.0" "@josephg/resolvable" "^1.0.0" - apollo-datasource "^3.0.2" + apollo-datasource "^3.3.0" apollo-graphql "^0.9.0" - apollo-reporting-protobuf "^3.0.0" - apollo-server-caching "^3.0.1" - apollo-server-env "^4.0.2" - apollo-server-errors "^3.0.1" - apollo-server-plugin-base "^3.0.2" - apollo-server-types "^3.0.2" + apollo-reporting-protobuf "^3.2.0" + apollo-server-caching "^3.3.0" + apollo-server-env "^4.2.0" + apollo-server-errors "^3.3.0" + apollo-server-plugin-base "^3.4.0" + apollo-server-types "^3.4.0" async-retry "^1.2.1" fast-json-stable-stringify "^2.1.0" graphql-tag "^2.11.0" @@ -1304,22 +1329,22 @@ apollo-server-core@^3.0.2: sha.js "^2.4.11" uuid "^8.0.0" -apollo-server-env@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-4.0.2.tgz#e21c283b0506584c96286cf1e59bb2952b4653d9" - integrity sha512-4SVYcW30o+/99M02yQl4zHiFWB11UE/We0lwgw/ylNvf7hsc7j6J0lQKITMqlt3ElFpIqPriEWqy4W5GmG9H2A== +apollo-server-env@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/apollo-server-env/-/apollo-server-env-4.2.0.tgz#d7cb08a81cee3025cd47b08be80b359d61d85913" + integrity sha512-4xJ+PCoWsFLj4rU6iXrIhqD7nI42goi4Iqrhsof9680ljSzkzd+PCwZsja3mHOFXKUQQUvJ7StVSgwaiRu45+A== dependencies: node-fetch "^2.6.1" -apollo-server-errors@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-3.0.1.tgz#0dfcc1fe8b10eab311fc7e4f6da93189ea6bcdae" - integrity sha512-PSp64IFeN1YK5EYZ3V/8iDRESMMyE00h1vE5aCr83wHL3T0mN7VRiMKoOIZ+2rUtnn7CpK73o6QLmouhxPtXsQ== +apollo-server-errors@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/apollo-server-errors/-/apollo-server-errors-3.3.0.tgz#ac8ceb1400064312f983d8d70195693fbcf2be3c" + integrity sha512-9/MNlPZBbEjcCdJcUSbKbVEBT9xZS8GSpX7T/TyzcxHSbsXJszSDSipQNGC+PRKTKAUnv61IONScVyLKEZ5XEQ== -apollo-server-express@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-3.0.2.tgz#0d83f0ab47cc3cc9a8b83b71c6690ac16976b02d" - integrity sha512-JQ3NS5Fm0ul4VMEVbIMG3Z26U1Ab7jMZ92DrToVu8wvdJKGAOZdlypLIn7odz6zlU7afZtCXyYhgc5Tb0DkAUA== +apollo-server-express@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/apollo-server-express/-/apollo-server-express-3.5.0.tgz#4675ba0e84dfd14bdbb47b5d0360928d701ee6b3" + integrity sha512-eFyBC4ate/g5GrvxM+HrtiElxCEbvG+CiJ0/R1i62L+wzXDhgD6MU0SW17ceS1mpBJgDxURu/VS5hUSNyWMa3Q== dependencies: "@types/accepts" "^1.3.5" "@types/body-parser" "1.19.1" @@ -1327,27 +1352,27 @@ apollo-server-express@^3.0.2: "@types/express" "4.17.13" "@types/express-serve-static-core" "4.17.24" accepts "^1.3.5" - apollo-server-core "^3.0.2" - apollo-server-types "^3.0.2" + apollo-server-core "^3.5.0" + apollo-server-types "^3.4.0" body-parser "^1.19.0" cors "^2.8.5" parseurl "^1.3.3" -apollo-server-plugin-base@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-3.0.2.tgz#645f8d2d0c21facfec9946d1a939869b10421fcd" - integrity sha512-WJ5PmGVUl67b41Z88EZDJcOqXFitsMbfyGDAqPQxeU2+bAl7+o1Oa9Hvx+qTsJKVKa9V+yS/nXFzZYpodehXEQ== +apollo-server-plugin-base@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/apollo-server-plugin-base/-/apollo-server-plugin-base-3.4.0.tgz#9fc26e9c9980f35e315a4c65d06b7970ee1dafa3" + integrity sha512-Z9musk7Z/1v+Db6aOoxcHfmsgej2yEBzBz5kVGOc81/XAtdv6bjasKSLC3RiySAUzWSLBJRUeEGIEVhhk/j2Zg== dependencies: - apollo-server-types "^3.0.2" + apollo-server-types "^3.4.0" -apollo-server-types@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-3.0.2.tgz#f47cdd20bad4eb00d029743e1d42f29d3dc0aa45" - integrity sha512-eZRLL96w9Ty/mV2j4QdoApNGRplwSNNPsAP9Wdlsf0eQ5WNFqgOWa/SQznyBXInlSrjhmnUaVjGZCsS9VoPD0w== +apollo-server-types@^3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/apollo-server-types/-/apollo-server-types-3.4.0.tgz#9af0322c79e95b698526646220f34534cba3cb11" + integrity sha512-iFNRENtxDoFWoY+KxpGP+TYyRnqUPqUTubMJVgiXPDvOPFL8dzqGGmqq1g/VCeWFHRJTPBLWhOfQU7ktwDEjnQ== dependencies: - apollo-reporting-protobuf "^3.0.0" - apollo-server-caching "^3.0.1" - apollo-server-env "^4.0.2" + apollo-reporting-protobuf "^3.2.0" + apollo-server-caching "^3.3.0" + apollo-server-env "^4.2.0" argparse@^1.0.7: version "1.0.10" @@ -2467,7 +2492,12 @@ graphql-upload@^12.0.0: isobject "^4.0.0" object-path "^0.11.5" -graphql@^15.3.0, graphql@^15.5.1: +graphql@16: + version "16.0.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.0.1.tgz#93a13cd4e0e38ca8d0832e79614c8578bfd34f10" + integrity sha512-oPvCuu6dlLdiz8gZupJ47o1clgb72r1u8NDBcQYjcV6G/iEdmE11B1bBlkhXRvV0LisP/SXRFP7tT6AgaTjpzg== + +graphql@^15.3.0: version "15.5.1" resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.1.tgz#f2f84415d8985e7b84731e7f3536f8bb9d383aad" integrity sha512-FeTRX67T3LoE3LWAxxOlW2K3Bz+rMYAC18rRguK4wgXaTZMiJwSUwDmPFo3UadAKbzirKIg5Qy+sNJXbpPRnQw== @@ -4450,6 +4480,11 @@ tslib@~2.2.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== +tslib@~2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" + integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -4616,6 +4651,11 @@ v8-to-istanbul@^8.0.0: convert-source-map "^1.6.0" source-map "^0.7.3" +value-or-promise@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/value-or-promise/-/value-or-promise-1.0.11.tgz#3e90299af31dd014fe843fe309cefa7c1d94b140" + integrity sha512-41BrgH+dIbCFXClcSapVs5M6GkENd3gQOJpEfPDNa71LsUGMXDL0jMWpI/Rh7WhX+Aalfz2TTS3Zt5pUsbnhLg== + value-or-promise@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/value-or-promise/-/value-or-promise-1.0.6.tgz#218aa4794aa2ee24dcf48a29aba4413ed584747f" From 91c449a437944600ada657b8cd8d350aa2965d7f Mon Sep 17 00:00:00 2001 From: Pieter Van der Haegen Date: Fri, 26 Nov 2021 16:28:10 +0100 Subject: [PATCH 2/2] test: test all functionality for every supported GraphQL version --- .github/workflows/pr.yml | 6 +++- .github/workflows/trunk.yml | 6 +++- package.json | 3 +- snapshot-resolver.js | 26 ++++++++++++++ ... => document-node.test.ts.graphql_14.snap} | 0 .../document-node.test.ts.graphql_15.snap | 35 +++++++++++++++++++ .../document-node.test.ts.graphql_16.snap | 34 ++++++++++++++++++ ...st.ts.snap => gql.test.ts.graphql_14.snap} | 0 .../__snapshots__/gql.test.ts.graphql_15.snap | 34 ++++++++++++++++++ .../__snapshots__/gql.test.ts.graphql_16.snap | 33 +++++++++++++++++ update-snapshots.sh | 14 ++++++++ 11 files changed, 188 insertions(+), 3 deletions(-) create mode 100644 snapshot-resolver.js rename tests/__snapshots__/{document-node.test.ts.snap => document-node.test.ts.graphql_14.snap} (100%) create mode 100644 tests/__snapshots__/document-node.test.ts.graphql_15.snap create mode 100644 tests/__snapshots__/document-node.test.ts.graphql_16.snap rename tests/__snapshots__/{gql.test.ts.snap => gql.test.ts.graphql_14.snap} (100%) create mode 100644 tests/__snapshots__/gql.test.ts.graphql_15.snap create mode 100644 tests/__snapshots__/gql.test.ts.graphql_16.snap create mode 100755 update-snapshots.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 514113b7c..10695c8cd 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,7 +10,8 @@ jobs: matrix: node: [12, 14, 16] environment: [dom, node] - name: Node ${{ matrix.node }} @env ${{matrix.environment}} + graphql-version: [14, 15, 16] + name: Node ${{ matrix.node }} @env ${{matrix.environment}} with grahpql@${{ matrix.graphql-version }} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -27,5 +28,8 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - run: yarn install + - run: yarn add graphql@${{ matrix.graphql-version }} - run: yarn build - run: yarn test:${{ matrix.environment }} + env: + GRAPHQL_VERSION: ${{ matrix.graphql-version }} diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index a63495657..001d69906 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -11,7 +11,8 @@ jobs: matrix: node: [12, 14, 16] environment: [dom, node] - name: Node ${{ matrix.node }} + graphql-version: [14, 15, 16] + name: Node ${{ matrix.node }} @env ${{matrix.environment}} with grahpql@${{ matrix.graphql-version }} steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -28,8 +29,11 @@ jobs: restore-keys: | ${{ runner.os }}-yarn- - run: yarn install + - run: yarn add graphql@${{ matrix.graphql-version }} - run: yarn build - run: yarn test:${{ matrix.environment }} + env: + GRAPHQL_VERSION: ${{ matrix.graphql-version }} release: needs: [tests] runs-on: ubuntu-latest diff --git a/package.json b/package.json index 137e8335b..b0ff768bd 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ }, "prettier": "@prisma-labs/prettier-config", "jest": { - "preset": "ts-jest" + "preset": "ts-jest", + "snapshotResolver": "/snapshot-resolver.js" } } diff --git a/snapshot-resolver.js b/snapshot-resolver.js new file mode 100644 index 000000000..9eba90b8e --- /dev/null +++ b/snapshot-resolver.js @@ -0,0 +1,26 @@ +const graphlExtension = '.graphql_' + (process.env.GRAPHQL_VERSION ? process.env.GRAPHQL_VERSION : '16') +const snapshotFolder = '/__snapshots__' + +// resolves from test to snapshot path +const resolveSnapshotPath = (testPath, snapshotExtension) => { + const indexOfLatestSlash = testPath.lastIndexOf('/') + return ( + testPath.substring(0, indexOfLatestSlash) + + snapshotFolder + + testPath.substring(indexOfLatestSlash) + + graphlExtension + + snapshotExtension + ) +} + +// resolves from snapshot to test path +const resolveTestPath = (snapshotFilePath, snapshotExtension) => + snapshotFilePath.replace(snapshotFolder, '').slice(0, -snapshotExtension.length - graphlExtension.length) + +module.exports = { + resolveSnapshotPath, + resolveTestPath, + + // Example test path, used for preflight consistency check of the implementation above + testPathForConsistencyCheck: 'tests/gql.test.ts', +} diff --git a/tests/__snapshots__/document-node.test.ts.snap b/tests/__snapshots__/document-node.test.ts.graphql_14.snap similarity index 100% rename from tests/__snapshots__/document-node.test.ts.snap rename to tests/__snapshots__/document-node.test.ts.graphql_14.snap diff --git a/tests/__snapshots__/document-node.test.ts.graphql_15.snap b/tests/__snapshots__/document-node.test.ts.graphql_15.snap new file mode 100644 index 000000000..a66869e1f --- /dev/null +++ b/tests/__snapshots__/document-node.test.ts.graphql_15.snap @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`accepts graphql DocumentNode as alternative to raw string 1`] = ` +Object { + "requests": Array [ + Object { + "body": Object { + "query": "{ + query { + users + } +} +", + }, + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip,deflate", + "connection": "close", + "content-length": "45", + "content-type": "application/json", + "host": "DYNAMIC", + "user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)", + }, + "method": "POST", + }, + ], + "spec": Object { + "body": Object { + "data": Object { + "foo": 1, + }, + }, + }, +} +`; diff --git a/tests/__snapshots__/document-node.test.ts.graphql_16.snap b/tests/__snapshots__/document-node.test.ts.graphql_16.snap new file mode 100644 index 000000000..3ca9f68e9 --- /dev/null +++ b/tests/__snapshots__/document-node.test.ts.graphql_16.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`accepts graphql DocumentNode as alternative to raw string 1`] = ` +Object { + "requests": Array [ + Object { + "body": Object { + "query": "{ + query { + users + } +}", + }, + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip,deflate", + "connection": "close", + "content-length": "43", + "content-type": "application/json", + "host": "DYNAMIC", + "user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)", + }, + "method": "POST", + }, + ], + "spec": Object { + "body": Object { + "data": Object { + "foo": 1, + }, + }, + }, +} +`; diff --git a/tests/__snapshots__/gql.test.ts.snap b/tests/__snapshots__/gql.test.ts.graphql_14.snap similarity index 100% rename from tests/__snapshots__/gql.test.ts.snap rename to tests/__snapshots__/gql.test.ts.graphql_14.snap diff --git a/tests/__snapshots__/gql.test.ts.graphql_15.snap b/tests/__snapshots__/gql.test.ts.graphql_15.snap new file mode 100644 index 000000000..be7356239 --- /dev/null +++ b/tests/__snapshots__/gql.test.ts.graphql_15.snap @@ -0,0 +1,34 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`gql passthrough allowing benefits of tooling for gql template tag 1`] = ` +Object { + "requests": Array [ + Object { + "body": Object { + "operationName": "allUsers", + "query": "query allUsers { + users +} +", + }, + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip,deflate", + "connection": "close", + "content-length": "69", + "content-type": "application/json", + "host": "DYNAMIC", + "user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)", + }, + "method": "POST", + }, + ], + "spec": Object { + "body": Object { + "data": Object { + "foo": 1, + }, + }, + }, +} +`; diff --git a/tests/__snapshots__/gql.test.ts.graphql_16.snap b/tests/__snapshots__/gql.test.ts.graphql_16.snap new file mode 100644 index 000000000..b6c6fb742 --- /dev/null +++ b/tests/__snapshots__/gql.test.ts.graphql_16.snap @@ -0,0 +1,33 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`gql passthrough allowing benefits of tooling for gql template tag 1`] = ` +Object { + "requests": Array [ + Object { + "body": Object { + "operationName": "allUsers", + "query": "query allUsers { + users +}", + }, + "headers": Object { + "accept": "*/*", + "accept-encoding": "gzip,deflate", + "connection": "close", + "content-length": "67", + "content-type": "application/json", + "host": "DYNAMIC", + "user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)", + }, + "method": "POST", + }, + ], + "spec": Object { + "body": Object { + "data": Object { + "foo": 1, + }, + }, + }, +} +`; diff --git a/update-snapshots.sh b/update-snapshots.sh new file mode 100755 index 000000000..e94056695 --- /dev/null +++ b/update-snapshots.sh @@ -0,0 +1,14 @@ +install_and_test() +{ + yarn add graphql@"$((GRAPHQL_VERSION))" --dev + yarn test +} + +export GRAPHQL_VERSION=14 +install_and_test + +export GRAPHQL_VERSION=15 +install_and_test + +export GRAPHQL_VERSION=16 +install_and_test