@@ -478,7 +478,17 @@ export function getResolver<TSource, TContext, TArgs>(
478
478
for ( const paramName in query ) {
479
479
const val = query [ paramName ] ;
480
480
if ( val !== undefined ) {
481
- urlObject . searchParams . set ( paramName , val ) ;
481
+ /**
482
+ * If the query parameter is an array, that means `explode: true` was set and we should append each key/value
483
+ * as a new search parameter. Else, it is a either a singular value or a comma-separated string of the values
484
+ * and we can just set the search parameter.
485
+ * https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
486
+ */
487
+ if ( Array . isArray ( val ) ) {
488
+ val . forEach ( v => urlObject . searchParams . append ( paramName , v ) ) ;
489
+ } else {
490
+ urlObject . searchParams . set ( paramName , val ) ;
491
+ }
482
492
}
483
493
}
484
494
@@ -1235,7 +1245,18 @@ export function extractRequestDataFromArgs<TSource, TContext, TArgs>(
1235
1245
1236
1246
// Query parameters
1237
1247
case 'query' :
1238
- qs [ param . name ] = args [ sanitizedParamName ] ;
1248
+ /**
1249
+ * Spec-compliant query string serialization:
1250
+ * http:pec.openapis.org/oas/v3.0.3#style-examples
1251
+ *
1252
+ * Whenever the query string value is an array, we check if it
1253
+ * should be `exploded`. In this case, we don't serialize anything.
1254
+ * Otherwise, the array will be joined in comma-separated fashion.
1255
+ */
1256
+ const arg = args [ sanitizedParamName ] ;
1257
+ const shouldBeCommaSeparated = Array . isArray ( arg ) && ! param . explode ;
1258
+
1259
+ qs [ param . name ] = shouldBeCommaSeparated ? arg . join ( ',' ) : arg ;
1239
1260
break ;
1240
1261
1241
1262
// Header parameters
0 commit comments