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

Field Expansion for Union and Interfaces misbehaving

Open mostafasany opened this issue 3 years ago • 0 comments

Description When Union or interfaces are sharing the same types too as in the bellow schema, too is expanded for all types(Foo and Bar), We expect shared fields are expand only for fields used in query

Given Schema


        type Query {
          uBaz: Baz
        }
        union Baz = Foo | Bar
        type Foo {
          foo: String
          too: String
        }
        type Bar {
          bar: Int
          too: String
        }
      `

and Query

 `
            query {
              uBaz {
                ... on Foo {
                  foo
                  too
                }
                ... on Bar {
                  bar
                }
              }
            }
          `

Expected info.fieldExpansion is

                  Object {
                    "Bar": Object {
                      "bar": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                    },
                    "Foo": Object {
                      "foo": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                      "too": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                    },
                  }

But Actual info.fieldExpansion is

                 Object {
                    "Bar": Object {
                      "bar": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                      "too": Object {     <--------- `too` is not expected as its not in the query   
                        Symbol(LeafFieldSymbol): true,
                      },
                    },
                    "Foo": Object {
                      "foo": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                      "too": Object {
                        Symbol(LeafFieldSymbol): true,
                      },
                    },
                  }
           

mostafasany avatar May 04 '21 21:05 mostafasany