@m1212e/rumble 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/index.cjs CHANGED
@@ -279,9 +279,8 @@ function makeGraphQLQueryRequest({ queryName, input, client, enableSubscription
279
279
  return promise;
280
280
  }
281
281
  function makeGraphQLMutationRequest({ mutationName, input, client, forceReactivity }) {
282
- const otwMutationName = `${(0, es_toolkit.capitalize)(mutationName)}Mutation`;
283
- const argsString = stringifyArgumentObjectToGraphqlList(input[argsKey] ?? {});
284
- const response = (0, wonka.pipe)(client.mutation(`mutation ${otwMutationName} { ${mutationName}${argsString} { ${stringifySelection(input)} }}`, {}), (0, wonka.map)((v) => {
282
+ const operationString = `mutation ${`${(0, es_toolkit.capitalize)(mutationName)}Mutation`} { ${mutationName}${stringifyArgumentObjectToGraphqlList(input[argsKey] ?? {})} { ${stringifySelection(input)} }}`;
283
+ const response = (0, wonka.pipe)(client.mutation(operationString, {}), (0, wonka.map)((v) => {
285
284
  const data = v.data?.[mutationName];
286
285
  if (!data && v.error) throw v.error;
287
286
  return data;
@@ -292,9 +291,8 @@ function makeGraphQLMutationRequest({ mutationName, input, client, forceReactivi
292
291
  return promise;
293
292
  }
294
293
  function makeGraphQLSubscriptionRequest({ subscriptionName, input, client, forceReactivity }) {
295
- const otwSubscriptionName = `${(0, es_toolkit.capitalize)(subscriptionName)}Subscription`;
296
- const argsString = stringifyArgumentObjectToGraphqlList(input[argsKey] ?? {});
297
- return (0, wonka.pipe)(client.subscription(`subscription ${otwSubscriptionName} { ${subscriptionName}${argsString} { ${stringifySelection(input)} }}`, {}), (0, wonka.map)((v) => {
294
+ const operationString = `subscription ${`${(0, es_toolkit.capitalize)(subscriptionName)}Subscription`} { ${subscriptionName}${stringifyArgumentObjectToGraphqlList(input[argsKey] ?? {})} { ${stringifySelection(input)} }}`;
295
+ return (0, wonka.pipe)(client.subscription(operationString, {}), (0, wonka.map)((v) => {
298
296
  const data = v.data?.[subscriptionName];
299
297
  if (!data && v.error) throw v.error;
300
298
  return data;
@@ -309,7 +307,8 @@ function stringifySelection(selection) {
309
307
  `;
310
308
  return acc;
311
309
  }
312
- acc += `${key} { ${stringifySelection(value)} }
310
+ acc += `${key} {
311
+ ${stringifySelection(value)} }
313
312
  `;
314
313
  } else acc += `${key}
315
314
  `;
@@ -318,11 +317,13 @@ function stringifySelection(selection) {
318
317
  }
319
318
  function stringifyArgumentObjectToGraphqlList(args) {
320
319
  const entries = Object.entries(args);
321
- if (entries.length === 0) return "";
322
- return `(${entries.map(([key, value]) => `${key}: ${stringifyArgumentValue(value)}`).join(", ")})`;
320
+ if (Array.isArray(args)) return `(${stringifyArgumentValue(args)})`;
321
+ if (entries.length > 0) return `(${entries.map(([key, value]) => `${key}: ${stringifyArgumentValue(value)}`).join(", ")})`;
322
+ return "";
323
323
  }
324
324
  function stringifyArgumentValue(arg) {
325
325
  if (arg === null) return "null";
326
+ if (Array.isArray(arg)) return `[${arg.map(stringifyArgumentValue).join(", ")}]`;
326
327
  switch (typeof arg) {
327
328
  case "string": return `"${arg}"`;
328
329
  case "number": return `${arg}`;