Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities subscription #25

Open
DiegoAlar opened this issue Jun 23, 2022 · 2 comments
Open

Entities subscription #25

DiegoAlar opened this issue Jun 23, 2022 · 2 comments

Comments

@DiegoAlar
Copy link

DiegoAlar commented Jun 23, 2022

Hi,

I'm having the following issue with the library in this part of the code:

*/
private function extractEntityTypes(array $config): array
{
$resolvedTypes = TypeInfo::extractTypes($config['query']);
$entityTypes = [];
foreach ($resolvedTypes as $type) {
if ($type instanceof EntityObjectType) {
$entityTypes[$type->name] = $type;
}
}
return $entityTypes;

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

Thank you!

@Aeliot-Tm
Copy link

Aeliot-Tm commented Aug 4, 2022

@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.

@magnusnordlander
Copy link

magnusnordlander commented Jan 24, 2023

@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 ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants