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

Allow interface fields to reference other interfaces (#1089) #1091

Merged

Conversation

jerelmiller
Copy link
Contributor

Closes #1089

It appears the DSL and the import_sdl differ in how interface types, with fields that themselves interfaces types, are compiled. When creating schemas via the DSL, compilation works as intended. I can create an interface that contains a field that is another interface type. When I do the same via import_sdl, compilation fails because it Absinthe thinks that the interface is not fully adhered to. This attempts to patch that behavior to ensure interface types can have fields that are themselves interfaces.

To ensure this use case is valid according to the GraphQL spec, I created a minimal reproduction of this schema using GraphQL.js to validate whether the SDL or the DSL had the correct behavior. It does indeed appear that interface types are allowed as fields to other interface types.

@jerelmiller
Copy link
Contributor Author

@binaryseed not sure if you're able to have a look, but I would love your input!

@jpvajda
Copy link

jpvajda commented Jul 30, 2021

It be cool to see this merged in soon! Looking forward to seeing this functionality.

@@ -191,6 +191,18 @@ defmodule Absinthe.Phase.Schema.Validation.ObjectMustImplementInterfaces do
:ok
end

defp check_covariant(
%Blueprint.TypeReference.Name{name: iface_name},
%Blueprint.TypeReference.Name{name: type_name},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I suspect the difference between the SDL & DSL is that only SDL currently generates the TypeReference blueprint structs everywhere... DSL winds up with bare-atom identifiers

This is a related note from a while back: #783

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're exactly right! Thats what I was seeing, just a bare atom in the case of the DSL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh nice find

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible difference in schema validation between DSL and import_sdl
4 participants