Question on intercepting GraphQL response #1
Labels
No labels
bug
dependencies
duplicate
enhancement
help wanted
invalid
javascript
question
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gucheen/fetchql#1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello, I have a question I cannot find an answer for and wonder if you can help or if this library can accommodate.
The server I am sending a request to returns a response that is not a JSON object - or graphQL map.
It is actually just returns a 200/ok with a string of comma-separated values like this...
0,4,Received and queued,0,,,0,,,
Each of the values in this string represent a key or name that I need to map so the client receives a readable response. The length of the string and number of values will remain constant.
For example, in this string....
value 1 (0) = 'hostResponseCode'
value 2 (4) = 'hostDetailCode'
value 3 (Received and queued) = 'hostMessage'
value 4 (0) = 'statusCode'
value 5 () = 'statusMessage'
value 6 () = 'etc'
...
I just read in the GraphQL specs in 7.2 Response Format that:
A response to a GraphQL operation must be a map.
Am I out of luck or is there a way I can intercept this response before it is received, assign it to a json object and map these fields? Is your library only for after the response is received?
Thank you for any feedback - this one has me perplexed as I would really like to graphQL my backend....
@rjpalermo1
Actually, FetchQL is a client-side tool of GraphQL. I think your problem lies in the server-side.
It is recommended to make all your responses to be maps(JSON).
Well, FetchQL provides interceptors that may help you deal with this situation if you could not change the response type in server-side.
Define a function in the interceptor's
responsefield to editresponse.data['OperationName']and transform it into JSON object.I wish I could. Thing is this server and code is tied to a financial institution and been certified and audited every 3 months. Making any changes to server code =
and a few months of documentation and re-certififcation. I have to take what I get.I'll give it a try, just downloaded your lib and now evaluating - I'm fairly green with js and brand new in graph - stumbled upon it yesterday while setting up swagger defs for the API ;) - not looking back.