apollographql / federation-jvm

JVM support for Apollo Federation

Home Page:https://www.apollographql.com/docs/federation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_entities error

elineback opened this issue · comments

I am seeing this error when I try to directly hit my federated app directly with a gateway query and I am wondering how I might fix it?
Screen Shot 2022-10-20 at 5 11 57 PM

It appears that the server library you are using (or your entities resolver) responds with null value instead of an array with null value inside.

demo-fed.zip
I made this super tiny app to replicate the issue. Not sure what you mean by server library? It is running on tomcat.

query
query($representations:[_Any!]!){
_entities(representations:$representations){
...on CcrcRecogConfig{configName}
}
}

{
"representations": [
{
"__typename": "CcrcRecogConfig",
"recogConfigUuid": "18f513c3-29b2-43e0-bfad-912e16facc86"
}
]
}

And I really appreciate your help.

Do I need to add some custom entity to this bean?
@bean
public GraphQlSourceBuilderCustomizer federationTransform() {
return builder -> {
builder.schemaFactory((registry, wiring)->
Federation.transform(registry, wiring)
.fetchEntities(env -> null)
.resolveEntityType(env -> null)
.build()
);
};
}

Do I need to add some custom entity to this bean?

Yes. You need to implement entity union type resolver (so server knows which object it is returning) and entities field data fetcher (it creates entities based on the passed in representation).

In your code above both type resolver and data fetcher are just returning null.

Ah ok. Thanks! Do you know if there are any examples of this I could look at?

Thanks again.