Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(GraphQL): Fix custom(dql: ...) with __typename (GRAPHQL-1098) (#7569
) This PR fixes the working of `@custom(dql: ...)` with `__typename` and fragments. Bug Description: 1. Apply GraphQL schema: ``` interface Node { id: ID! } type User implements Node { name: String } type Token implements Node { key: String } type Query { queryNodeR: [Node] @Custom(dql: """ query { queryNodeR(func: type(Node)) { dgraph.type id: uid name: User.name key: Token.key } } """) } ``` 2. Add data: ``` mutation { addUser(input: [{name: "User1"}]) {numUids} addToken(input: [{key: "Token1"}]) {numUids} } ``` 3. Query with both the auto-generated and the custom query and see the difference: ``` query { queryNode { id __typename ... UserFrag ... TokenFrag } queryNodeR { id __typename ... UserFrag ... TokenFrag } } fragment UserFrag on User { name } fragment TokenFrag on Token { key } ``` 4. The response being returned was: ``` { "data": { "queryNode": [ { "id": "0x2", "__typename": "User", "name": "User1" }, { "id": "0x3", "__typename": "Token", "key": "Token1" } ], "queryNodeR": [ { "id": "0x2", "__typename": "Node", "name": "User1", "key": null }, { "id": "0x3", "__typename": "Node", "name": null, "key": "Token1" } ] } } ``` `queryNodeR` should have had the same result as `queryNode`.
- Loading branch information