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

IMPROVE: Message when @list directive and graphql client type error #483

Merged
merged 2 commits into from
Aug 25, 2022
Merged
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
5 changes: 5 additions & 0 deletions .changeset/stale-foxes-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini': patch
---

fix: check field existence before @list directive to have better error msg
20 changes: 20 additions & 0 deletions src/cmd/validators/typeCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ const table: Row[] = [
`,
],
},
{
title: '@list on query on field that doesn t exist',
pass: false,
documents: [
`
query TestQuery {
user {
friends_NOT_EXISTING_FIELD @list(name: "Friends") {
id
}
}
}
`,
],
check: (e: any) => {
expect(e.message).toMatchInlineSnapshot(
'"Could not find definition of friends_NOT_EXISTING_FIELD in User"'
)
},
},
{
title: '@list with parentID on query',
pass: true,
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/validators/typeCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ export default async function typeCheck(
// @ts-ignore
// look at the next entry for a list or something else that would make us
// require a parent ID
rootType = rootType?.getFields()[parent.name.value].type
// if [parent.name.value] doesnt't exist, the document is not valid and it will be catch later
rootType = rootType?.getFields()[parent.name.value]?.type
}

// if we found a pagination directive, make sure that it doesn't
Expand Down