Skip to content
New issue

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

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

Already on GitHub? # to your account

Validate type references for invalid wrapped types #1195

Merged
merged 2 commits into from
Sep 12, 2022

Conversation

maartenvanvliet
Copy link
Contributor

In some places we were not checking for invalid wrapped types (non-null/list). E.g.

union :my_union do
  types [:boolean, list_of(:id)]
end

Or when using import_fields or interface with a wrapped type.

This PR adds the missing checks in the TypeReferencesExist phase. All cases where a wrapped type is invalid are now caught in this phase.

What still needs to be tackled is whether the types passed in are valid for that case. A union's types can only consist of object types, interfaces can only refer to interface definitions etc. This could be done in a separate phase. Some of this work is (incidentally) tackled by other phases but I think it makes sense to group this.

Fixes #1048

In some places we were not checking for invalid wrapped types
(non-null/list). E.g.
```elixir
union :my_union do
  types [:boolean, list_of(:id)]
end
```

Or when using `import_fields` or `interface` with a wrapped type.

This PR adds the missing checks in the TypeReferencesExist phase. All
cases where a wrapped type is invalid are now caught in this phase.

What still needs to be tackled is whether the types passed in are valid
for that case. A union's types can only consist of object types, interfaces
can only refer to interface definitions etc. This could be done in a
separate phase. Some of this work is (incidentally) tackled by other
phases but I think it makes sense to group this.

Fixes absinthe-graphql#1048
@benwilson512 benwilson512 merged commit 3c98e41 into absinthe-graphql:master Sep 12, 2022
@maartenvanvliet maartenvanvliet deleted the validate-unions branch September 13, 2022 04:33
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid union arguments has a bad error message
2 participants