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

'interfaces' on interface should be an empty list #960

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

yanns
Copy link
Contributor

@yanns yanns commented Feb 9, 2023

Follow-up of #956

Steps to reproduce:

{
  __schema {
    types {
      name
      interfaces {
        name
      }
    }
  }
}

returns:

...
{ "name" : "SomeInterfaceName", "interfaces" : null } 
...

but according to specs it should return:

...
{ "name" : "SomeInterfaceName", "interfaces" : [] } 
...

More details: https://spec.graphql.org/October2021/#sec-The-__Type-Type.Interface

interfaces must return the set of interfaces that an object implements (if none, interfaces must return the empty set).

Knowing that sangria does not support interfaces of interfaces for now, we just change the introspection result to render an empty array instead of null.

@@ -272,7 +272,7 @@ package object introspection {
"interfaces",
OptionType(ListType(__Type)),
resolve = _.value._2 match {
case t: ObjectType[_, _] =>
case t: ObjectLikeType[_, _] =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ObjectLikeType regroups ObjectType and InterfaceType

Copy link
Contributor

Choose a reason for hiding this comment

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

💯

Copy link
Contributor

@nikola-mladenovic nikola-mladenovic left a comment

Choose a reason for hiding this comment

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

🎉

@yanns yanns merged commit 7784f91 into main Feb 9, 2023
@yanns yanns deleted the fix-interface-introspection-response branch February 9, 2023 16:34
yanns added a commit that referenced this pull request Feb 10, 2023
The change #960
introduces some support for interfaces of interface.

But this feature is not complete: it would need something like
#597 for full support.

Right now, sometimes we support interfaces of interface and sometimes now.

To avoid this configuration, let's always return an empty list.

We can tackle the complete support for interfaces of interface later.
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.

2 participants