@requires field that @requires also a field

Hello

I have 2 subgraphs: Progression & Course
In the Progression subgraph I have this:

  type UserProgression @key(fields: "_id") {
    _id: ID
    videoId: ID
    videoInfos: JSONObject @external
    update(progress: Int, lastPosition: Int, timeSpent: Int): Boolean @requires(fields: "videoInfos")
  }

And in the Course subgraph I have this:

  extend type UserProgression @key(fields: "_id") {
    _id: ID @external
    videoId: ID @external
    videoInfos: JSONObject @requires(fields: "videoId")
  }

What I was expecting it to do is that when i call update, it calls the resolveReference videoInfos which will call the resolveReference videoId.
But i get the error : “INTERNAL_SERVER_ERROR: Cannot create a selection set from an empty path”
When i try to call just videoInfos it works, and when i call update after removing the @requires from videoInfos it also works. I guess the problem here is that a required field is calling another required field.

Is there any solution for that ?

In theory this should work, at least with recent federation versions. And the code has some unit test for such @requires that chains other @requires (here) so it’s not immediately obvious what specific to your example create an issue (and thus hard to recommend any workaround).

I’d say make sure that you are on a recent version, and if you’re still running into this, opening a github issue (GitHub - apollographql/federation: 🌐  Build and scale a single data graph across multiple services with Apollo's federation gateway.) with more details to help us reproduce would be much appreciated.

Hi, thanks for your reply,
I found out how to fix it, i just replaced the _id in the @key by videoId like this

type UserProgression @key(fields: "videoId") 

Problem is i have no idea why this works and not the other one ._.