Question on intercepting GraphQL response #1

Closed
opened 2016-06-23 11:46:51 +08:00 by rjpalermo1 · 2 comments
rjpalermo1 commented 2016-06-23 11:46:51 +08:00 (Migrated from github.com)

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....

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....
gucheen commented 2016-06-23 12:10:55 +08:00 (Migrated from github.com)

@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 response field to edit response.data['OperationName'] and transform it into JSON object.

@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 `response` field to edit `response.data['OperationName']` and transform it into JSON object.
rjpalermo1 commented 2016-06-23 12:21:22 +08:00 (Migrated from github.com)

It is recommended to make all your responses to be maps(JSON).

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.

Define a function in the interceptor's response field to edit response.data['OperationName'] and transform it into JSON object.

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.

> It is recommended to make all your responses to be maps(JSON). 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. > Define a function in the interceptor's response field to edit response.data['OperationName'] and transform it into JSON object. 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gucheen/fetchql#1
No description provided.