-
Notifications
You must be signed in to change notification settings - Fork 23
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
Basic support for virtual fields using hydration #600
Conversation
lib/src/main/java/graphql/nadel/engine/blueprint/NadelFieldInstruction.kt
Outdated
Show resolved
Hide resolved
...kotlin/graphql/nadel/tests/next/fixtures/hydration/virtual/HydrationMakesVirtualFieldTest.kt
Outdated
Show resolved
Hide resolved
lib/src/main/java/graphql/nadel/engine/blueprint/NadelVirtualTypeBlueprintFactory.kt
Outdated
Show resolved
Hide resolved
...kotlin/graphql/nadel/tests/next/fixtures/hydration/virtual/HydrationMakesVirtualFieldTest.kt
Outdated
Show resolved
Hide resolved
lib/src/main/java/graphql/nadel/engine/blueprint/NadelExecutionBlueprintFactory.kt
Outdated
Show resolved
Hide resolved
lib/src/main/java/graphql/nadel/engine/blueprint/directives/NadelHydrationDirective.kt
Show resolved
Hide resolved
lib/src/main/java/graphql/nadel/engine/transform/NadelServiceTypeFilterTransform.kt
Outdated
Show resolved
Hide resolved
lib/src/main/java/graphql/nadel/engine/transform/hydration/NadelHydrationTransform.kt
Outdated
Show resolved
Hide resolved
...src/main/java/graphql/nadel/engine/transform/hydration/batch/NadelBatchHydrationTransform.kt
Outdated
Show resolved
Hide resolved
...raphql/nadel/tests/next/fixtures/hydration/virtual/HydrationMakesVirtualFieldTestSnapshot.kt
Outdated
Show resolved
Hide resolved
sourceNode: JsonNode, | ||
sourceIds: List<List<Any?>>, | ||
resultNodesByObjectId: Map<List<Any?>, JsonMap>, | ||
): NadelResultInstruction { | ||
val hydratedFieldDef = NadelTransformUtil.getOverallFieldDef( |
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.
This is redundant, it looks up the field definition using the __typename
in the result, but that's already been done because we've resolved an instruction at the call site.
This change just passes in the instruction and looks an the field definition in the instruction.
Likely this was a mistake due to copy paste during refactoring.
"VirtualEcho" to "BackingEcho", | ||
"VirtualEchoInfo" to "BackingEchoInfo", | ||
), | ||
) |
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.
Question -
So when we make a virtual type - we say that all fields in other types get made "virtual" as well - eg the shape of virtual type is actually the backing type shapes
What happens if the types reference themselves
type VirtualEcho {
echo: String
info: VirtualEchoInfo
selfReference : VirtualEcho. # what happens here
}
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.
will it go into a infinite loop and if not can we have a test for that?
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.
There's code to protect against that, I've created a test for that though.
} | ||
] | ||
) | ||
} |
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.
Does this code have a "get all other parameters" and stuff them into a map code yet?
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.
Not yet, coming in another PR.
Branch is https://github.com/atlassian-labs/nadel/tree/remaining-arguments
So the phrase virtual fields here refers to a
@hydrated
field at the top level that doesn't use any$source
arguments.Though in a new branch I've repurposed it and renamed
hydratedField
etc. to virtual field and actor field to backing field.