openapi-to-graphql icon indicating copy to clipboard operation
openapi-to-graphql copied to clipboard

Adds query string serialization optimization

Open akoenig opened this issue 4 years ago • 2 comments

👋

This PR introduces the serialization of the query string, when the explode attribute has been set. When defined the actual serialization includes a duplication of the parameter. Otherwise arrays will be serialized in a comma-separated way.

Example with explode turned off:

http://localhost:3004/api/robots?types=Droid%2CBot

Example with explode turned on:

http://localhost:3004/api/robots?types=Droid&types=Bot

This also activates the useQuerystring mode in request so that the query string gets encoded properly (#308).

I ran into the "problem" today, when using query string parameters which are typed as arrays and wanted to help to fix that. So this is my PR 🙂

akoenig avatar Apr 17 '20 18:04 akoenig

@akoenig This is an awesome change!!! Thank you so much! We're in the middle of trying to get our 2.1.0 version out and I will try to get this in right after!

Alan-Cha avatar Apr 20 '20 20:04 Alan-Cha

@Alan-Cha @akoenig how will this work when you have a nested object ?

> q = {filter: { first_name: 'hello', last_name: 'world'}}
{ filter: { first_name: 'hello', last_name: 'world' } }
> querystring.stringify(q)
'filter='

papatego avatar Jun 15 '20 13:06 papatego