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

validation allows null for non-nullable list items #738

Closed
qwerdenkerXD opened this issue Nov 11, 2023 · 1 comment · Fixed by #746
Closed

validation allows null for non-nullable list items #738

qwerdenkerXD opened this issue Nov 11, 2023 · 1 comment · Fixed by #746
Assignees
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation bug Something isn't working

Comments

@qwerdenkerXD
Copy link

Description

When having arguments of type List with non-nullable items, such as e.g. [String!],
the validation doesn't recognize a violation if I pass a list with null-values.

Steps to reproduce

Imagine having this schema:

type Query {
  foo(arg: [String!]!): String!
  bar(arg: [String!]): String!
}

and validating the following query:

{
  a: foo(arg: [null])
  b: foo(arg: [null, null, "hello"])
  bar(arg: [null])
}

Here a code sample.

Expected result

The validation should identify the violation and append it to the diagnostic list.

Actual result

The validation doesn't notice the violation, no such error in diagnostics. (also in version 0.11.3)

Environment

  • Operating system and version: Ubuntu 20.04.6 LTS
  • Shell (bash/zsh/powershell): zsh
  • apollo-rs crate: apollo-compiler
  • Crate version: 1.0.0-beta.6
@qwerdenkerXD qwerdenkerXD added bug Something isn't working triage labels Nov 11, 2023
@goto-bus-stop goto-bus-stop self-assigned this Nov 13, 2023
@goto-bus-stop goto-bus-stop added apollo-compiler issues/PRs pertaining to semantic analysis & validation and removed triage labels Nov 13, 2023
@qwerdenkerXD
Copy link
Author

Just checked it for input objects, same issue if an input object field expects such list type.

goto-bus-stop added a commit that referenced this issue Nov 16, 2023
…sition (#746)

* chore(compiler): add regression test for #738

* chore(compiler): remove 2 suffix from method names

* fix(compiler): raise a diagnostic for null items in a non-nullable list

* clippy

* test nested list inside object

* fix(compiler): null type is never assignable to a non-null type and always assignable to a nullable type

* chore(compiler): add failing test for providing list to non-list type

* Use name from ExtendedType where possible

* fix(compiler): reject list values provided to non-list types

* port value tests from graphql-js

* only instantiate the test schema once

* Use #[track_caller]

Co-authored-by: Simon Sapin <[email protected]>

* Use `ExtendedType::is_input_type` instead of manual match

* Assert diagnostics output for the graphql-js value type tests

* remove excess whitespace from test schema and queries

Used the runtime `unindent` crate instead of compile-time `indoc` so it doesn't need to be repeated at every call site.

* Remove outdated comment

---------

Co-authored-by: Simon Sapin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants