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

transformsResponse returns data as a string, vs a JSON object #6

Open
stephenbaldwin opened this issue Mar 31, 2020 · 1 comment
Open

Comments

@stephenbaldwin
Copy link
Contributor

api.mount('ExampleQuery')
      .transformResponse(
         (response) => {
             const json = JSON.parse(response); // Response is a string. It should already be an object
          }
      )
@Mk-Etlinger
Copy link

Mk-Etlinger commented Mar 31, 2020

Hey @stephenbaldwin, I made some progress here but I want to run it by you before I submit a PR.

If you look at https://github.com/Econify/graphql-rest-router/blob/master/Router.ts#L53-L61

You'll see the config for axios and since we're not including transformResponse, there's no default behavior.

Edit: After digging into this issue a bit more, I was on the wrong track above. More accurately, by using transformReponse and giving it your own transform function, we're overriding the default. This issue is about maintaining the default transformResponse even when you're using your own custom transform as well.

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

Successfully merging a pull request may close this issue.

2 participants