-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature: add support for interface resolution #21
Feature: add support for interface resolution #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
lib/federation.js
Outdated
|
||
if (type && 'then' in type && typeof type.then === 'function') { | ||
return type.then((resolvedType) => { | ||
const resolveReference = resolvedType.resolveReference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const resolveReference = resolvedType.resolveReference | |
const resolveReference = resolvedType.resolveReference || function defaultResolveReference () { | |
return reference | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
const type = info.schema.getType(__typename) | ||
|
||
if (!type || !(isObjectType(type) || isInterfaceType(type))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont understand this:
first we check isInterfaceType(type)
and we throw
then we check !isInterfaceType(type)
and we return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first check verifies that the type is allowed to continue the type resolution (should be an object or an interface). The second if discriminate between the object and the interface, when is an object type there is no need to call resolveType
function because the typename is already defined.
lib/federation.js
Outdated
} | ||
|
||
const resolveTypeFn = type.resolveType | ||
? type.resolveType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can shorthand this
const resolveTypeFn = type.resolveType
? type.resolveType
: defaultTypeResolver
with
const resolveTypeFn = type.resolveType || defaultTypeResolver;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
simplify promise checks Co-authored-by: Marco Ippolito <marcoippolito54@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (@mcollina I dont have permissions on this repo for some reason)
I've removed by accident jonnygreen as reviewer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay in reviewing, LGTM!
This implementation will enable the resolution of a GraphQL interface requested by the federation.
The resolution will be accessible using the entity resolution by putting as
typename
the interface as the following exampleNode schema
Query