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
14 changes: 0 additions & 14 deletions jest.config.js

This file was deleted.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest",
"test:watch": "jest --watch",
"test": "tsx --test test/**/*.test.ts",
"test:watch": "tsx --test --watch test/**/*.test.ts",
"bench:tree": "tsx benchmark/tree.ts",
"bench:list": "tsx benchmark/list.ts",
"bench:tree-list": "tsx benchmark/tree_list.ts",
Expand All @@ -23,12 +23,9 @@
"graphql": "^16.9.0"
},
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"dataloader": "^2.2.3",
"jest": "^29.7.0",
"ts-jest": "^29.1.2",
"tsx": "^4.21.0",
"tsx": "^4.22.0",
"typescript": "^5.4.5"
},
"engines": {
Expand Down
2,870 changes: 158 additions & 2,712 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions test/abort_execution/abort_execution.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assert from "node:assert/strict";
import { beforeEach, describe, test } from "node:test";
import { buildSchema } from "graphql";
import {
Executor,
Expand Down Expand Up @@ -119,7 +121,7 @@ describe("abort execution", () => {
source,
);

expect(result).toEqual({
assert.deepStrictEqual(result, {
errors: [{
message: "Cannot return null for non-nullable field Query.must",
path: ["mayList", 0, "must"],
Expand All @@ -132,7 +134,7 @@ describe("abort execution", () => {
},
});

expect(EventCollector.events).toEqual([
assert.deepStrictEqual(EventCollector.events, [
"mayList",
"mustObj",
"may",
Expand All @@ -156,8 +158,8 @@ describe("abort execution", () => {
source,
);

expect(result.data).toBeNull();
expect(EventCollector.events).toEqual([
assert.strictEqual(result.data, null);
assert.deepStrictEqual(EventCollector.events, [
"mustObj",
"mayList",
"must",
Expand Down Expand Up @@ -187,7 +189,7 @@ describe("abort execution", () => {
source,
);

expect(result).toEqual({
assert.deepStrictEqual(result, {
errors: [{
message: "Cannot return null for non-nullable field Query.must",
extensions: { code: "INVALID_NULL" },
Expand All @@ -202,7 +204,7 @@ describe("abort execution", () => {
},
});

expect(EventCollector.events).toEqual([
assert.deepStrictEqual(EventCollector.events, [
"mayList",
"mustObj",
"mustObj",
Expand Down
26 changes: 14 additions & 12 deletions test/arguments/arguments.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assert from "node:assert/strict";
import { describe, test } from "node:test";
import { buildSchema } from "graphql";
import { Executor, FieldResolver, type ResolverMap } from "../../src";
import type { ExecutionField } from "../../src/executor/execution_field";
Expand Down Expand Up @@ -64,28 +66,28 @@ function run(query: string, variables: Record<string, unknown> = {}) {
describe("argument coercion (graphql-js native)", () => {
test("applies argument default values", () => {
const { result, echo } = run(`{ echo(value: "hi") }`);
expect(result).toEqual({ data: { echo: "hi" } });
expect(echo.lastArgs).toEqual({ value: "hi", count: 1 });
assert.deepStrictEqual(result, { data: { echo: "hi" } });
assert.deepStrictEqual(echo.lastArgs, { value: "hi", count: 1 });
});

test("coerces enum literals to their external values", () => {
const { result, echo } = run(`{ echo(value: "hi", color: RED, count: 2) }`);
expect(result).toEqual({ data: { echo: "hi-REDhi-RED" } });
expect(echo.lastArgs).toEqual({ value: "hi", color: "RED", count: 2 });
assert.deepStrictEqual(result, { data: { echo: "hi-REDhi-RED" } });
assert.deepStrictEqual(echo.lastArgs, { value: "hi", color: "RED", count: 2 });
});

test("substitutes variables with type coercion", () => {
const { result, echo } = run(
`query ($v: String!, $n: Int, $c: Color) { echo(value: $v, count: $n, color: $c) }`,
{ v: "yo", n: 3, c: "BLUE" },
);
expect(result).toEqual({ data: { echo: "yo-BLUEyo-BLUEyo-BLUE" } });
expect(echo.lastArgs).toEqual({ value: "yo", count: 3, color: "BLUE" });
assert.deepStrictEqual(result, { data: { echo: "yo-BLUEyo-BLUEyo-BLUE" } });
assert.deepStrictEqual(echo.lastArgs, { value: "yo", count: 3, color: "BLUE" });
});

test("coerces input objects with nested defaults", () => {
const { result } = run(`{ bucket(filter: { min: 3 }) }`);
expect(result).toEqual({
assert.deepStrictEqual(result, {
data: { bucket: [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] },
});
});
Expand All @@ -95,15 +97,15 @@ describe("argument coercion (graphql-js native)", () => {
`query ($c: Color!) { echo(value: "x", color: $c) }`,
{ c: "MAUVE" },
);
expect(result.data).toBeUndefined();
expect(result.errors?.length).toBe(1);
expect(result.errors?.[0]?.message).toMatch(/MAUVE/);
assert.strictEqual(result.data, undefined);
assert.strictEqual(result.errors?.length, 1);
assert.match(result.errors?.[0]?.message ?? "", /MAUVE/);
});

test("surfaces invalid argument literals as field errors", () => {
// Passing a non-existent enum literal is caught by graphql-js validation.
const { result } = run(`{ echo(value: "x", color: PURPLE) }`);
expect(result.errors?.length).toBeGreaterThanOrEqual(1);
expect(result.errors?.[0]?.message).toMatch(/PURPLE|Color/);
assert.ok((result.errors?.length ?? 0) >= 1);
assert.match(result.errors?.[0]?.message ?? "", /PURPLE|Color/);
});
});
Loading