Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Custom directive fired for key field #1044

@JLambertNowNZ

Description

@JLambertNowNZ

I'm experiencing an issue where since moving from Apollo Gateway to Hive Gateway, a custom directive is being called when I wouldn't anticipate it to (and isn't called when using Apollo Gateway). To set a rough scene:

Subgraph 1

extend schema @link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key"])

directive @auth(scopes: [String!]) on FIELD_DEFINITION

extend type Query {
  getPlayerById(id: ID!): Player
}

type Player @key(fields: "id") @key(fields: "internalReference") {
  id: ID!
  name: String!
  internalReference: String! @auth(scopes: ["internal"])
}

Subgraph 2

type Player @key(fields: "internalReference") {
  internalReference: String!
  someOtherInfo: String!
}

Query

query getPlayerById($id: GUID!) {
  getPlayerById(id: $id) {
    id
    name
  }
}

Despite the query above not including the likes of the internalReference field, I'm finding the @auth directive attached to the field is being called. I find this is only the case given a key field is referenced across subgraphs. For example, if Subgraph 2 instead keyed on id instead of internalReference, the query would work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions