Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ jobs:
run: yarn check:${{ matrix.check }}

test:
name: Test
strategy:
fail-fast: false
matrix:
include:
- graphql: 17
node: 24
- graphql: 16
node: 22
name: Test GraphQL ${{ matrix.graphql }} on Node ${{ matrix.node }}
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
Expand All @@ -44,9 +52,15 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version: ${{ matrix.node }}
cache: yarn
- name: Install
- name: Install GraphQL 17 baseline
if: matrix.graphql == 17
run: yarn install --immutable
- name: Install GraphQL 16 compatibility baseline
if: matrix.graphql == 16
run: yarn add --dev graphql@^16.8.1
- name: Check types
run: yarn check:type
- name: Test
run: yarn test
run: yarn test --run
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v21
v24
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"implementations/**/*"
],
"peerDependencies": {
"graphql": ">=0.11 <=16"
"graphql": ">=0.11 <=17"
},
"devDependencies": {
"@cspell/cspell-types": "^8.1.2",
Expand All @@ -137,7 +137,7 @@
"express": "^4.18.2",
"fastify": "^4.24.3",
"glob": "^10.3.10",
"graphql": "^16.8.1",
"graphql": "^17.0.0",
"html-validator": "^6.0.1",
"koa": "^2.15.3",
"koa-mount": "^4.0.0",
Expand All @@ -151,7 +151,7 @@
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.3.2",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.34.0",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.69.0",
"vitest": "^1.0.1"
}
}
6 changes: 1 addition & 5 deletions tests/audits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ describe('Render audit results to HTML', () => {
htmlValidator({
data: document,
}),
).resolves.toMatchInlineSnapshot(`
{
"messages": [],
}
`);
).resolves.toMatchObject({ messages: [] });
});
});
41 changes: 9 additions & 32 deletions tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,38 +41,15 @@ it('should use the provided headers', async () => {
const [request] = texecute(client, { query: '{ hello }' });
await request;

expect(headers).toMatchInlineSnapshot(`
Headers {
Symbol(headers list): HeadersList {
"cookies": null,
Symbol(headers map): Map {
"x-some" => {
"name": "x-some",
"value": "header",
},
"content-type" => {
"name": "content-type",
"value": "application/json; charset=utf-8",
},
"accept" => {
"name": "accept",
"value": "application/graphql-response+json, application/json",
},
},
Symbol(headers map sorted): null,
},
Symbol(guard): "request",
Symbol(realm): {
"settingsObject": {
"baseUrl": undefined,
"origin": undefined,
"policyContainer": {
"referrerPolicy": "strict-origin-when-cross-origin",
},
},
},
}
`);
expect(headers).toBeInstanceOf(Headers);
const actualHeaders = headers as unknown as Headers;
expect(actualHeaders.get('x-some')).toBe('header');
expect(actualHeaders.get('content-type')).toBe(
'application/json; charset=utf-8',
);
expect(actualHeaders.get('accept')).toBe(
'application/graphql-response+json, application/json',
);
});

it('should execute query, next the result and then complete', async () => {
Expand Down
35 changes: 20 additions & 15 deletions tests/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,28 @@ it('should respond with error if execution result is iterable', async () => {
it('should correctly serialise execution result errors', async () => {
const { request } = createTHandler({ schema });

await expect(
request('GET', {
query: 'query ($num: Int) { num(num: $num) }',
variables: { num: 'foo' },
}),
).resolves.toMatchInlineSnapshot(`
[
"{"errors":[{"message":"Variable \\"$num\\" got invalid value \\"foo\\"; Int cannot represent non-integer value: \\"foo\\"","locations":[{"line":1,"column":8}]}]}",
const [body, init] = await request('GET', {
query: 'query ($num: Int) { num(num: $num) }',
variables: { num: 'foo' },
});

expect(JSON.parse(body!)).toEqual({
errors: [
{
"headers": {
"content-type": "application/graphql-response+json; charset=utf-8",
},
"status": 200,
"statusText": "OK",
message: expect.stringContaining(
'Int cannot represent non-integer value: "foo"',
),
locations: [{ line: 1, column: 8 }],
},
]
`);
],
});
expect(init).toEqual({
headers: {
'content-type': 'application/graphql-response+json; charset=utf-8',
},
status: 200,
statusText: 'OK',
});
});

it('should append the provided validation rules array', async () => {
Expand Down
21 changes: 14 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7604,7 +7604,7 @@ __metadata:
express: "npm:^4.18.2"
fastify: "npm:^4.24.3"
glob: "npm:^10.3.10"
graphql: "npm:^16.8.1"
graphql: "npm:^17.0.0"
html-validator: "npm:^6.0.1"
koa: "npm:^2.15.3"
koa-mount: "npm:^4.0.0"
Expand All @@ -7618,10 +7618,10 @@ __metadata:
typedoc: "npm:^0.25.4"
typedoc-plugin-markdown: "npm:^3.17.1"
typescript: "npm:^5.3.2"
uWebSockets.js: "uNetworking/uWebSockets.js#v20.34.0"
uWebSockets.js: "uNetworking/uWebSockets.js#v20.69.0"
vitest: "npm:^1.0.1"
peerDependencies:
graphql: ">=0.11 <=16"
graphql: ">=0.11 <=17"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -7738,6 +7738,13 @@ __metadata:
languageName: node
linkType: hard

"graphql@npm:^17.0.0":
version: 17.0.2
resolution: "graphql@npm:17.0.2"
checksum: e3760187b08cafd0755cc504bf272623cba8a05c29671c9ec5709fe634aaf62011a98e7831f67add3775261a0617e1b0d548da99ab70532b72d6dd5e1f0915ca
languageName: node
linkType: hard

"handlebars@npm:^4.7.7":
version: 4.7.8
resolution: "handlebars@npm:4.7.8"
Expand Down Expand Up @@ -12349,10 +12356,10 @@ __metadata:
languageName: node
linkType: hard

"uWebSockets.js@uNetworking/uWebSockets.js#v20.34.0":
version: 20.34.0
resolution: "uWebSockets.js@https://github.com/uNetworking/uWebSockets.js.git#commit=fca27c05066342b01951782248640c8013b37196"
checksum: 589d8de66f66f260396efdcecd712e1d1a4427ec58210d83632afe9ef689eccb43aa5c7b67f99ef3e88cabbdf51c0518e10aff99071cef0883b00dd795a85aa9
"uWebSockets.js@uNetworking/uWebSockets.js#v20.69.0":
version: 20.69.0
resolution: "uWebSockets.js@https://github.com/uNetworking/uWebSockets.js.git#commit=dddd8ffd1b2c28a66022160923ca92f064cdacb4"
checksum: 1b7798d06990a034316a2d46590b478b43fb8011aabd845b467399de4de9399f6e9c4fc0d43e07a4fffdc98c2f05b0e9f6a4912ba8048eb390f77da673739dca
languageName: node
linkType: hard

Expand Down