-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,9 +86,11 @@ Meta.test("typecheck", async (t) => { | |
await t.should("generate validation code for valid queries", () => { | ||
const code = getValidationCode(queryGetPosts); | ||
|
||
const formattedCode = nativeResult(native.typescript_format_code({ | ||
source: code, | ||
}))!.formatted_code; | ||
const formattedCode = nativeResult( | ||
native.typescript_format_code({ | ||
source: code, | ||
}), | ||
)!.formatted_code; | ||
|
||
console.log("asserting snapshot", { formattedCode }); | ||
t.assertSnapshot(formattedCode); | ||
|
@@ -110,15 +112,11 @@ Meta.test("typecheck", async (t) => { | |
const validate = getValidator(queryGetPosts); | ||
t.assertThrowsSnapshot(() => validate({ posts: [post1] })); | ||
|
||
t.assertThrowsSnapshot( | ||
() => validate({ posts: [post2] }), | ||
); | ||
t.assertThrowsSnapshot(() => validate({ posts: [post2] })); | ||
|
||
validate({ posts: [post3] }); | ||
|
||
t.assertThrowsSnapshot( | ||
() => validate({ posts: [post3, post2] }), | ||
); | ||
t.assertThrowsSnapshot(() => validate({ posts: [post3, post2] })); | ||
|
||
const validate2 = getValidator(graphql` | ||
query GetPosts { | ||
|
@@ -141,83 +139,90 @@ Meta.test("typecheck", async (t) => { | |
email: "my email", | ||
}; | ||
|
||
t.assertThrowsSnapshot( | ||
() => | ||
validate2({ | ||
posts: [ | ||
{ | ||
...post1, | ||
author: user, | ||
}, | ||
], | ||
}), | ||
t.assertThrowsSnapshot(() => | ||
validate2({ | ||
posts: [ | ||
{ | ||
...post1, | ||
author: user, | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
t.assertThrowsSnapshot( | ||
() => | ||
validate2({ | ||
posts: [{ | ||
t.assertThrowsSnapshot(() => | ||
validate2({ | ||
posts: [ | ||
{ | ||
...post1, | ||
author: { ...user, id: crypto.randomUUID() }, | ||
}], | ||
}), | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
t.assertThrowsSnapshot( | ||
() => | ||
validate2({ | ||
posts: [{ | ||
t.assertThrowsSnapshot(() => | ||
validate2({ | ||
posts: [ | ||
{ | ||
...post1, | ||
author: { | ||
id: crypto.randomUUID(), | ||
username: "john", | ||
email: "[email protected]", | ||
website: "example.com", | ||
}, | ||
}], | ||
}), | ||
}, | ||
], | ||
}) | ||
); | ||
|
||
validate2({ | ||
posts: [{ | ||
...post1, | ||
author: { | ||
id: crypto.randomUUID(), | ||
username: "john", | ||
email: "[email protected]", | ||
posts: [ | ||
{ | ||
...post1, | ||
author: { | ||
id: crypto.randomUUID(), | ||
username: "john", | ||
email: "[email protected]", | ||
}, | ||
}, | ||
}], | ||
], | ||
}); | ||
|
||
validate2({ | ||
posts: [{ | ||
...post1, | ||
author: { | ||
id: crypto.randomUUID(), | ||
username: "john", | ||
email: "[email protected]", | ||
website: "https://example.com", | ||
posts: [ | ||
{ | ||
...post1, | ||
author: { | ||
id: crypto.randomUUID(), | ||
username: "john", | ||
email: "[email protected]", | ||
website: "https://example.com", | ||
}, | ||
}, | ||
}], | ||
], | ||
}); | ||
}); | ||
|
||
await t.should("accept explicit null value", async () => { | ||
await gql` | ||
query { | ||
findProduct( | ||
name: "A" | ||
equivalent: [ | ||
{ name: "B", equivalent: null }, | ||
{ name: "C", score: null }, | ||
{ name: "D", score: 10 }, | ||
], | ||
score: null | ||
name: "A" | ||
equivalent: [ | ||
{ name: "B", equivalent: null } | ||
{ name: "C", score: null } | ||
{ name: "D", score: 10 } | ||
] | ||
score: null | ||
) { | ||
name | ||
equivalent { | ||
name | ||
equivalent { name } | ||
equivalent { | ||
name | ||
} | ||
score | ||
} | ||
score | ||
|
@@ -227,11 +232,7 @@ Meta.test("typecheck", async (t) => { | |
.expectData({ | ||
findProduct: { | ||
name: "A", | ||
equivalent: [ | ||
{ name: "B" }, | ||
{ name: "C" }, | ||
{ name: "D", score: 10 }, | ||
], | ||
equivalent: [{ name: "B" }, { name: "C" }, { name: "D", score: 10 }], | ||
score: null, | ||
}, | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters