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

Nullable interface fields cannot have their implementing sub-type be non-nullable. #987

Closed
nickdichev opened this issue Nov 2, 2020 · 0 comments · Fixed by #1009
Closed
Labels

Comments

@nickdichev
Copy link

Environment

  • Elixir version (elixir -v): Elixir 1.11.1 (compiled with Erlang/OTP 23)
  • Absinthe version (mix deps | grep absinthe): absinthe 1.5.3 (Hex package) (mix)
  • Client Framework and version (Relay, Apollo, etc): N/A getting compilation error

Expected behavior

The schema compiles and the implementing sub-type is valid.

Actual behavior

Compilation error

Type "header_cell" does not fully implement interface type "manifest_cell" for fields [:text]
...
  * An object field type is a valid sub-type if it is a Non-Null variant of a
    valid sub-type of the interface field type.

Relevant Schema/Middleware Code

  interface :manifest_cell do
    field :text, :string
  end

  object :header_cell do
    field :text, non_null(:string)

    interface :manifest_cell
    is_type_of &is_struct(&1, HeaderCell)
  end
maartenvanvliet added a commit to maartenvanvliet/absinthe that referenced this issue Dec 25, 2020
Fixes absinthe-graphql#987

Two cases are added to the schema:
 * a simple nullable interface -> non-nullable implementor.
 * a nullable list -> with implementors `list_of(non_null(type))` and
   `non_null(list_of(non_null(type)))`.

From my reading of the spec these should all validate.

https://spec.graphql.org/draft/#IsValidImplementationFieldType()

I did find that it is not validated whether the object implements
the field's arguments. Also that the object does not implement
extra non-nullable arguments that are not specified in the interface,
this is not allowed. I'll create an issue for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants