Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(graphql): add TypedDocumentNode inference tests #2018

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"devDependencies": {
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@graphql-typed-document-node/core": "^3.2.0",
"@open-draft/test-server": "^0.4.2",
"@ossjs/release": "^0.8.1",
"@playwright/test": "^1.40.1",
Expand Down
12 changes: 11 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions test/typings/graphql-typed-document.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { graphql, HttpResponse } from 'msw'
import { TypedDocumentNode } from '@graphql-typed-document-node/core'

const GetUserQuery = {} as TypedDocumentNode<
{
user: {
name: 'John'
}
},
{ userId: string }
>

graphql.query(GetUserQuery, ({ variables }) => {
variables.userId.toUpperCase()

return HttpResponse.json({
data: {
user: { name: 'John' },
},
})
})

graphql.query(GetUserQuery, ({ variables }) => {
// @ts-expect-error Unknown variable
variables.unknownVariable

return HttpResponse.json({
data: {
user: { name: 'John' },
},
})
})

graphql.query(
GetUserQuery,
// @ts-expect-error Invalid response type.

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.7)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.8)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.9)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.0)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.1)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.2)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.3)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3

Check failure on line 36 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.4)

graphql-typed-document.test-d.ts

TypeCheckError: Unused '@ts-expect-error' directive. ❯ graphql-typed-document.test-d.ts:36:3
() => {
return HttpResponse.json({
data: {
user: { name: 123 },

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.7)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.8)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (4.9)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.0)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.1)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.2)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.3)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17

Check failure on line 40 in test/typings/graphql-typed-document.test-d.ts

View workflow job for this annotation

GitHub Actions / typescript (5.4)

graphql-typed-document.test-d.ts

TypeCheckError: Type 'number' is not assignable to type '"John"'. ❯ graphql-typed-document.test-d.ts:40:17
},
})
},
)
3 changes: 2 additions & 1 deletion test/typings/tsconfig.4.7.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"moduleResolution": "Node16"
"moduleResolution": "Node16",
"lib": ["DOM", "DOM.Iterable"]
}
}
Loading