Setting an alias on __type() returns no data

We are working on updating our Graph to Apollo v4. As we are running tests have noticed that a query which is aliasing __type() returns no data ({}). Is this expected behavior? The query returns data in our v3 configuration. If this should work perhaps we aren’t setting something up correctly.

Example

Returns as expected:

query getAllSessionLocationDestination {
 	__type (name:"SessionLocationDestination") {
		name
    enumValues {
      name
      description
    }
  }
}

Doesn’t return any data ("data": {} ):

query getAllSessionLocationDestination {
  TargetLocationEnums: 
	__type (name:"SessionLocationDestination") {
		name
    enumValues {
      name
      description
    }
  }
}

The difference being the alias on __type

Upon further investigation the both the above queries work if run against the subgraph which contains that enum. It’s only through the gateway the above issue is seen.

Versions;
@apollo/gateway: 2.4.0
@apollo/server: 4.5.0
@apollo/subgraph: 2.4.0
@graphql: 16.6.0

Reproduce at codesandbox: inspiring-rain-6biu2h - CodeSandbox

   ReviewTypes: __type(name: "ReviewType") {
    name
    enumValues {
      name
      description
    }
  }
}```

Issue fixed in Fix handling of aliases and variables in introspection queries by pcmanus · Pull Request #2506 · apollographql/federation · GitHub

1 Like