apollo-federation-php icon indicating copy to clipboard operation
apollo-federation-php copied to clipboard

Entities subscription

Open DiegoAlar opened this issue 3 years ago • 2 comments

Hi,

I'm having the following issue with the library in this part of the code: https://github.com/Skillshare/apollo-federation-php/blob/4f958ddb683c1fceb1d162f58a5dc2957e26fe5d/src/FederatedSchema.php?rgh-link-date=2022-06-23T15%3A36%3A45Z#L215-L227

The issue is that the library is unable to subscribe entities that aren't returned by a query.

Thank you!

DiegoAlar avatar Jun 23 '22 15:06 DiegoAlar

@DiegoAlar Could you describe your problem more verbose?

P.s. Provide link to exact version instead of main branch, please. Otherwise, it might be broken after the merging of any changes.

Aeliot-Tm avatar Aug 04 '22 15:08 Aeliot-Tm

@Aeliot-Tm I think we're experiencing the same issue, in which case the issue is that if a type is not directly or indirectly referenced by the Query type, the type is not discovered as an entity.

Consider the following sub-graph schemas:

# Subgraph A

extend type Query {
	restaurants: [Restaurant!]!
}

type Restaurant {
	id: ID! @key
	name: String!
}


# Subgraph B

extend type Query {
	locations: [Location!]!
}

type Location {
	lat: Float!
	long: Float!
}

extend type Restaurant {
	id: ID! @key
	location: Location!
}

Note that in Subgraph B, the Query type does not reference the Restaurant Type. If this schema is implemented using this library, it is unable to discover that the Restaurant type is an Entity, because Apollo\Federation\FederatedSchema::extractEntityTypes gets its list of candidate types from $config['query'] (cf. https://github.com/Skillshare/apollo-federation-php/blob/4f958dd/src/FederatedSchema.php#L218 ).

magnusnordlander avatar Jan 24 '23 09:01 magnusnordlander