Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-8776] UDG does not handle union as query result #4974

Open
agata-wit opened this issue Apr 25, 2023 · 2 comments
Open

[TT-8776] UDG does not handle union as query result #4974

agata-wit opened this issue Apr 25, 2023 · 2 comments
Labels
bug graphql needed for graphql project

Comments

@agata-wit
Copy link

Branch/Environment/Version

  • Branch/Version: master
  • Environment: all affected

Describe the bug
In case union is defined as the result of a UDG query operation with REST data sources, even though all data comes back from the upstream, the response doesn't resolve.
Described as well in community forum: https://community.tyk.io/t/using-union-on-tyk-udg-with-rest-datasource/6296

Reproduction steps
With the following schema:

type Query {
  getUser(id:Int):UserUnion
}
union UserUnion = User | CustomError


type CustomError{
  code: String
  message: String
}

type User{
  id:Int
  name:String
}

connecting a REST data source to getUser doesn't resolve correctly on response.
Response from upstream:

  • correct from debug logs: /data (afterFetchHook.OnData): {“user”:{“id”:1,“name”:“Bob”,“status”:“PENDING”,“accessories”:[“A”,“B”,“C”]}}
  • error from debug logs: /data (afterFetchHook.OnData): {“error”:{“code”:“ERR_01”,“message”:“some error”}}

Actual behavior
After running a query this is the response:
image

Expected behavior
Response should contain data parsed from the upstream.

@agata-wit agata-wit added bug graphql needed for graphql project labels Apr 25, 2023
@agata-wit agata-wit changed the title UDG does not handle union as query result [TT-8776] UDG does not handle union as query result Apr 25, 2023
@dennissetiawan
Copy link

dennissetiawan commented Apr 26, 2023

There are also case where tyk does not forward the query correctly with GraphQL datasource. Check this reply https://community.tyk.io/t/using-union-on-tyk-udg-with-rest-datasource/6296/6?u=midnight

@agata-wit
Copy link
Author

We will check if it's related or not. Thanks for the comment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug graphql needed for graphql project
Projects
None yet
Development

No branches or pull requests

2 participants