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

Fix bug where no instructions are found for a given object #505

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -373,23 +373,27 @@ internal class NadelNewBatchHydrator(
sourceObjects: List<JsonNode>,
): List<SourceObjectMetadata> {
return sourceObjects
.map { sourceObject ->
.mapNotNull { sourceObject ->
val instructions = instructionsByObjectTypeNames.getInstructionsForNode(
executionBlueprint = executionBlueprint,
service = sourceFieldService,
aliasHelper = aliasHelper,
parentNode = sourceObject,
)

val sourceIdsPairedWithInstructions = getInstructionParingForSourceIds(
sourceObject = sourceObject,
instructions = instructions,
)
if (instructions.isEmpty()) {
null
} else {
val sourceIdsPairedWithInstructions = getInstructionParingForSourceIds(
sourceObject = sourceObject,
instructions = instructions,
)

SourceObjectMetadata(
sourceObject,
sourceIdsPairedWithInstructions,
)
SourceObjectMetadata(
sourceObject,
sourceIdsPairedWithInstructions,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: "new no object fields in the result are backed a batch hydration"
enabled: true
# language=GraphQL
overallSchema:
activity: |
type Query {
activity: [IActivity]
}
interface IActivity {
user: User
}
type Activity implements IActivity {
id: ID!
user: User
@hydrated(
service: "users"
field: "usersByIds"
arguments: [{name: "ids" value: "$source.userId"}]
inputIdentifiedBy: [{sourceId: "userId" resultId: "id"}]
)
}
type SingleActivity implements IActivity {
id: ID!
user: User
}
users: |
type Query {
usersByIds(ids: [ID!]!): [User]
}
type User {
id: ID!
name: String
}
# language=GraphQL
underlyingSchema:
activity: |
type Query {
activity: [IActivity]
}
type User {
id: ID!
name: String
}
interface IActivity {
user: User
}
type Activity implements IActivity {
id: ID!
userId: ID
user: User @deprecated(reason: "Fake")
}
type SingleActivity implements IActivity {
id: ID!
user: User
}
users: |
type Query {
usersByIds(ids: [ID!]!): [User]
}
type User {
id: ID!
name: String
}
# language=GraphQL
query: |
{
activity {
user {
name
}
}
}
variables: { }
serviceCalls:
- serviceName: "activity"
request:
# language=GraphQL
query: |
{
activity {
... on Activity {
__typename__batch_hydration__user: __typename
batch_hydration__user__userId: userId
}
... on SingleActivity {
user {
name
}
}
}
}
variables: { }
# language=JSON
response: |-
{
"data": {
"activity": [
{
"user": {
"name": "John"
}
},
{
"user": {
"name": "Mayor"
}
}
]
},
"extensions": {}
}
# language=JSON
response: |
{
"data": {
"activity": [
{
"user": {
"name": "John"
}
},
{
"user": {
"name": "Mayor"
}
}
]
},
"errors": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: "new no object fields in the result are backed a hydration"
enabled: true
# language=GraphQL
overallSchema:
activity: |
type Query {
activity: [IActivity]
}
interface IActivity {
user: User
}
type Activity implements IActivity {
id: ID!
user: User
@hydrated(
service: "users"
field: "userById"
arguments: [{name: "id" value: "$source.userId"}]
)
}
type SingleActivity implements IActivity {
id: ID!
user: User
}
users: |
type Query {
userById(id: ID!): User
}
type User {
id: ID!
name: String
}
# language=GraphQL
underlyingSchema:
activity: |
type Query {
activity: [IActivity]
}
type User {
id: ID!
name: String
}
interface IActivity {
user: User
}
type Activity implements IActivity {
id: ID!
userId: ID
user: User @deprecated(reason: "Fake")
}
type SingleActivity implements IActivity {
id: ID!
user: User
}
users: |
type Query {
userById(id: ID!): User
}
type User {
id: ID!
name: String
}
# language=GraphQL
query: |
{
activity {
user {
name
}
}
}
variables: { }
serviceCalls:
- serviceName: "activity"
request:
# language=GraphQL
query: |
{
activity {
... on Activity {
__typename__hydration__user: __typename
hydration__user__userId: userId
}
... on SingleActivity {
user {
name
}
}
}
}
variables: { }
# language=JSON
response: |-
{
"data": {
"activity": [
{
"user": {
"name": "John"
}
},
{
"user": {
"name": "Mayor"
}
}
]
},
"extensions": {}
}
# language=JSON
response: |
{
"data": {
"activity": [
{
"user": {
"name": "John"
}
},
{
"user": {
"name": "Mayor"
}
}
]
},
"errors": []
}
Loading
Loading