graphql-engine/server/src-lib/Hasura/GraphQL
Auke Booij be7f34891c server: give stack traces when encountering conflicting type definitions (#150)
Since PDV, introspection queries are parsed by a certain kind of reflection where during the GraphQL schema generation, we collect all GraphQL types used during schema generation to generate answers to introspection queries. This has a great advantage, namely that we don't need to keep track of which types are being used in our schema, as this information is extracted after the fact.

But what happens when we encounter two types with the same name in the GraphQL schema? Well, they better be the same, otherwise we likely made a programming error. So what do we do when we *do* encounter a conflict? So far, we've been throwing a rather generic error message, namely `found conflicting definitions for <typename> when collecting types from the schema`. It does not specify what the conflict is, or how it arose. In fact, I'm a little bit hesitant to output more information about what the conflict is, because we support many different kinds of GraphQL types, and these can have disagreements in many different ways. It'd be a bit tiring (not to mention error-prone) to spell this out explicitly for all types. And, in any case, at the moment our equality checks for types is incorrect anyway, as we are avoiding implementing a certain recursive equality checking algorithm.

As it turns out, type conflicts arise not just due to programming errors, but also arise naturally under certain configurations. @codingkarthik encountered an interesting case recently where adding a specific remote and a single unrelated database table would result in a conflict in our Relay schema. It was not readily visible how this conflict arose: this took significant engineering effort.

This adds stack traces to type collection, so that we can inform the user where the type conflict is taking place. The origin of the above conflict can easily be spotted using this PR. Here's a sample error message:

```
Found conflicting definitions for "PageInfo". The definition at "mutation_root.UpdateUser.favourites.anime.edges.node.characters.pageInfo" differs from the the definition at "query_root.test_connection.pageInfo"
```

Co-authored-by: Antoine Leblanc <antoine@hasura.io>
GitOrigin-RevId: d4c01c243022d8570b3c057b168a61c3033244ff
2020-12-04 15:37:55 +00:00
..
Execute server: don't memoize backend scalar type reps through WithScalarType (#136) 2020-12-03 12:22:24 +00:00
Parser server: give stack traces when encountering conflicting type definitions (#150) 2020-12-04 15:37:55 +00:00
Schema server: don't memoize backend scalar type reps through WithScalarType (#136) 2020-12-03 12:22:24 +00:00
Transport Disallow caching for remote joins with forwarded headers (master) (#58) 2020-12-01 23:24:24 +00:00
Context.hs server: make the UnpreparedValue less tightly bound to the backend (#108) 2020-11-25 16:08:27 +00:00
Execute.hs server: make the UnpreparedValue less tightly bound to the backend (#108) 2020-11-25 16:08:27 +00:00
Explain.hs server: don't memoize backend scalar type reps through WithScalarType (#136) 2020-12-03 12:22:24 +00:00
Logging.hs server: metadata storage abstraction for scheduled triggers 2020-11-25 10:57:38 +00:00
Parser.hs server: schema that grows (#105) 2020-12-01 15:51:13 +00:00
RemoteServer.hs server: make more use of hlint (#6059) 2020-10-28 16:40:33 +00:00
Schema.hs server: give stack traces when encountering conflicting type definitions (#150) 2020-12-04 15:37:55 +00:00
Utils.hs server: make more use of hlint (#6059) 2020-10-28 16:40:33 +00:00