tailcallhq / tailcall

High Performance GraphQL Runtime
https://tailcall.run
Apache License 2.0
1.3k stars 256 forks source link

Bug in the nested queries when working with @graphql #3088

Open MedHeikelBouzayene opened 4 weeks ago

MedHeikelBouzayene commented 4 weeks ago

Prerequisites

Describe the bug

Let's have this schema:

schema @server(port: 8000, hostname: "0.0.0.0") {
  query: Query
}

type Query {
  queryNodeA: NodeA @graphQL(url: "http://localhost:8083", name: "nodeA")
}

type NodeA {
  name: String
  nodeB: NodeB
  nodeC: NodeC
}

type NodeB {
  name: String
  nodeA: NodeA
  nodeC: NodeC
}

type NodeC {
  name: String
  nodeA: NodeA
  nodeB: NodeB
}

when I send try this query:

query QueryNodeA {
    queryNodeA {
        name
        nodeB {
            name
        }
        nodeC {
            name
        }
    }
}

that's the query sent to the graphql server: > Body { "query": "query { nodeA { name nodeB { name } nodeC } }" }

Expected behavior

That's the query expected to be sent to the graphql server:

Body

{ "query": "query { nodeA { name nodeB { name } nodeC { name } } }" }

tusharmath commented 3 weeks ago

This can be fixed by adding a jit/transform/graphql.rs. This transformer will be responsible to building the exact GraphQL query for each source GraphQL query.