-
Notifications
You must be signed in to change notification settings - Fork 153
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
Nested aggregations 6 #5993
Nested aggregations 6 #5993
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.
Left some comments, but LGTM otherwise!
const isTargetUnion = relationshipAdapter.target instanceof UnionEntityAdapter; | ||
const isSourceInterface = relationshipAdapter.source instanceof InterfaceEntityAdapter; | ||
|
||
if (relationshipAdapter.isAggregable() && !isTargetUnion && !isSourceInterface) { |
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 think the method isAggregable
can hold the logic for isTargetUnion
and isSourceInterface
so that can be used a single source of truth
fields["aggregate"] = `${relationshipAdapter.operations.getAggregationFieldTypename()}!`; | ||
} | ||
|
||
const connectionObjectType = composer.createObjectTC({ |
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.
Nitpick: you can create the objectTC
first with the shared fields and then use the composer.addFields
if needed for the aggregate field.
const isSourceInterface = relationshipAdapter.source instanceof InterfaceEntityAdapter; | ||
|
||
if (relationshipAdapter.isAggregable() && !isTargetUnion && !isSourceInterface) { | ||
fields["aggregate"] = `${relationshipAdapter.operations.getAggregationFieldTypename()}!`; |
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.
fields["aggregate"] = `${relationshipAdapter.operations.getAggregationFieldTypename()}!`; | |
fields["aggregate"] = composer.getOTC(relationshipAdapter.operations.getAggregationFieldTypename()).NonNull; |
} | ||
const relationshipObjectType = composer.createObjectTC({ | ||
name: typeName, | ||
fields: { cursor: new GraphQLNonNull(GraphQLString), node: `${relationshipAdapter.target.name}!` }, |
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.
fields: { cursor: new GraphQLNonNull(GraphQLString), node: `${relationshipAdapter.target.name}!` }, | |
fields: { cursor: new GraphQLNonNull(GraphQLString), node: composer.getOTC(relationshipAdapter.target.name).NonNull }, |
@@ -43,6 +43,7 @@ export class ConnectionAggregationField extends Field { | |||
}) { | |||
super(alias); | |||
this.operation = operation; | |||
this.operation.isInConnectionField = true; |
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.
If possible I would handle this in the factory rather than on the constructor
typeDefs = ` | ||
type ${typeMovie.name} @node { | ||
title: String | ||
${typeActor.plural}: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") |
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.
${typeActor.plural}: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") | |
actors: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") |
This is applicable also below
typeDefs = ` | ||
type ${typeMovie.name} @node { | ||
title: String | ||
${typeActor.plural}: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") |
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.
${typeActor.plural}: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") | |
actors: [${typeActor.name}!]! @relationship(type: "ACTED_IN", direction: IN, properties:"ActedIn") |
same below
Description
Support for nested aggregations inside connections