question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Query variables parameter is badly serialized when using GET method in production

See original GitHub issue

Intended outcome:

I would like to use a GET method to allow query caching using httpLink.create({uri, method: 'GET'})

Actual outcome:

This works correctly for development with ng serve but when built for production or using ng serve --prod the variables query parameter is serialized as [object Object] instead of {"currency":"USD"}

I can see there is a test assertion but I’m not too sure how it can be executed with production optimizations: https://github.com/apollographql/apollo-angular/blob/d185116b2d2306a40b12db747a058621211e2e92/packages/apollo-angular-link-http/tests/HttpLink.spec.ts#L205

How to reproduce the issue:

Example: https://github.com/mrfoster/ng-apollo-link-bug-1

Steps to recreate:

  • ng new apollo-angular-test
  • ng add apollo-angular
  • Change the line in graphql.module.ts from httpLink.create({uri}) to httpLink.create({uri, method: 'GET'})
  • Create a query that accepts variables
query Rates($currency: String!) {
  rates(currency: $currency) {
    currency
    rate
  }
}
  • Start using ng serve --prod

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrfostercommented, Feb 27, 2019
0reactions
kamilkisielacommented, Mar 18, 2019

Please bump apollo-angular-link-http-common to 1.5.1, it contains a fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong Query parameter serialization when using Object #8615
We are using objects in query parameters for a get operations, when we call the service, object parameters are not serialized as expected....
Read more >
OpenAPI query string parameter with list of objects
and contains a list of object with properties id and value . My yaml documentation looks like the following parameters: - name: filtered...
Read more >
Parameter Serialization - Swagger
Parameter Serialization · style defines how multiple values are delimited. Possible styles depend on the parameter location – path, query, header or cookie....
Read more >
Guide to Spring Boot REST API Error Handling - Toptal
Implement consumer-friendly support to a Spring Boot REST API by hiding implementation details and delivering easily digestible fields.
Read more >
Customizing the ReSTful interface - Flask-Restless
All endpoints which respond with data respond with serialized JSON strings. GET ... For more information on search parameters, see Making search queries....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found