timqian / gql-generator

Generate queries from graphql schema, used for writing api test.
MIT License
376 stars 93 forks source link

Confusing behaviour ignoring types #25

Open Adam-Burke opened 5 years ago

Adam-Burke commented 5 years ago

As this tool is used for tests, it expands all of the fields in a query. There might be recursive fields in the query, so gqlg ignores the types which have been added in the parent queries already.

The current behaviour only returns the first matched query in the depth first traversal behaviour not the shallowest in the tree. Is this what the above intends?

So if you have object nesting like the following

thing {
    thing {
        thing2 {
             thing3 {
                  thing4
              }
        }
    }
    thing3 {
       thing4
    }
}

Depending on the order of your fields it will return different queries. Some with the thing.thing3.thing4 and others with it nested inside thing.thing2.thing3.thing4.

Sorry I'm new to this stuff. My terminology sucks. Hope I'm making some sense.

Adam-Burke commented 5 years ago

Seems this pr is trying to address this issue.

https://github.com/timqian/gql-generator/pull/13/files