graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Fusion is unable to make query from Subgraph1 to Subgraph 2 and back to Subgraph1

Open phuc1640 opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Product

Hot Chocolate

Describe the bug

I currently have 2 subgraph, one is called Department, the other is called Employee.

Department graph

In Department graph, there are two Object type: Department and User. Both of this objects follow Relay Specification.

Here is Department subgraph Schema

type Query {
    departmentById(id: ID!): Department!
}

type Department {
    id: ID!
    group: String!
    headOfDepartment: Employee!
}

type User {
    id: ID!
    userName: String!
    firstName: String!
    lastName: String!
}

type Employee {
    id: ID!
}

Because inside Department we have field called headOfDepartment that is Employee type, and because of compliance issue, we need to have Employee data from Employee subgraph. Because of this we have another type call Employee inside Department subgraph that only have ID field.

Employee graph

In Employee graph, there is Employee type that have all the related data from Employee. This objects also follow Relay Specification.

Here is Employee subgraph Schema

type Query {
    employeeById(id: ID!): Employee!
}

type Employee {
    id: ID!
    salary: Int!
    user: User!
}

type User {
    id: ID!
}

As you can see, the Employee needs User information, and those data is coming from Department subgraph. So that why we also have a User type inside Employee subgraph that just have ID field

Fusion graph

We use fusion to merge all of these field and type from those 2 subgraph.

For fusion gateway, after fusion, we have the following queries

type Query {
    departmentById(id: ID!): Department!
    employeeById(id: ID!): Employee!
}

If we make a query from fusion gateway like below

query departmentById($id: ID!) {
    departmentById(id: $id) {
        id
        headOfDepartment {
            id
            salary
            user {
                id
                userName
                firstName
                lastName
            }
        }
    }
}

Then for some reason, we do not received field userName, firstName, lastName from user. They are omited from the returning result.

{
    "data": {
        "departmentById": {
            "id": "departmentId",
            "headOfDepartment": {
                "id": "headOfDepartmentId",
                "salary": 100,
                "user": {
                    "id": "userId"
                }
            }
        }
    }
}

But if we make a query like below

query employeeById($id: ID!) {
    employeeById(id: $id) {
        id
        salary
        user {
            id
            userName
            firstName
            lastName
        }
    }
}

Then we have data for field userName, firstName, lastName from user.

{
    "data": {
        "employeeById": {
            "id": "employeeId",
            "salary": 100,
            "user": {
                "id": "userId",
                "firstName": "firstName",
                "lastName": "lastName"
            }
        }
    }
}

I think this is and issue with Fusion, could you take a look at this

Steps to reproduce

Relevant log output

No response

Additional Context?

No response

Version

13.7.1-preview.2

phuc1640 avatar Nov 21 '23 07:11 phuc1640