I have 2 subgraphs. Subgraph 2 wants to add new field to a type defined in subgraph1.
This new field defined in subgraph 2, requires data from subgraph 1. I was able to successfully achieve this with @requires
directive. I was reading the documentation and it says that in order to share the data the subgraph also need to defined __resolveReference along with @requires. But I was able to achieve this with my normal resolver without __resolveReference.
Is __resolveReference Optional? Do we need only @requires to get the data from other subgraph?
Example:
There are 2 subgraph A and B.
Subgraph A has a type T1:
type T1 @key(fields: "id") {
id: Int!
name: String
}
Subgraph B:
extend type T1 @key(fields: "id") {
id: Int! @external
name: String @external
newField: String @requires(fields: "name")
}
Resolver for Subgraph B:
T1: {
newField(obj){
// obj contains data `id` and `name` from subgraph A
return "newFieldData"
}
}
Here I was able to get name in subgraph B without definining __resolveReference in Subgraph A.