@requires - field cannot be included as it has arguments

I have a federated architecture, I am updating our gateway from v0 to v2 (there is no v1)

Currently I am getting a field that has an argument attached to it (optionally used) from another federated service as external and gateway IntrospectAndCompose composition complains about it


Service 1:

type A @key(fields: name) {
  name: String
  options(test: String): Options

type Options {
  code: Int

Service 2:

extend type A @key(fields: name) {
  name: String @external
  options(test:String): Options @external

  newField: Int @requires(options { code } )

So above in my Service 2 the newField field requires code from the nested object defined in Service 1 to resolve it

But with the above syntax I get an error saying I cannot pass options field (which has code within it) as it has an optional argument attached to it

Side Notes:

  • Gateway was not complaining about this in v1 - it could be because now v2 is more accurate in surfacing errors but in practice this configuration was working fine
  • option(test:String): Option @external the argument in Service 2 (test:String) was added after the upgrade since composition service was complaining about not having this argument
    Field “typeA.options” is missing argument “typeA.options(test:)” in some subgraphs where it is marked @external

Hello, have you found a solution to your problem ? I’m facing the same situation

Hello :wave:

Ability for @requires to reference fields with nullable/optional arguments is tracked under Federation 2 - Prevents @requires directive to accept fields with arguments - Allow it for Nullable Arguments · Issue #1987 · apollographql/federation · GitHub and should be supported soon.