Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/batch-execute

Package Overview
Dependencies
Maintainers
4
Versions
700
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/batch-execute - npm Package Compare versions

Comparing version 9.0.7 to 9.0.8-alpha-5fb7ce042dd8c2edbe8ba8947d94342a59270992

43

CHANGELOG.md
# @graphql-tools/batch-execute
## 9.0.8-alpha-5fb7ce042dd8c2edbe8ba8947d94342a59270992
### Patch Changes
- [#243](https://github.com/graphql-hive/gateway/pull/243) [`5fb7ce0`](https://github.com/graphql-hive/gateway/commit/5fb7ce042dd8c2edbe8ba8947d94342a59270992) Thanks [@ardatan](https://github.com/ardatan)! - Fix the issue that batched query generation when optional variables are not prefixed and sent correctly.
See the use case below;
When two batched queries are sent like below;
```graphql
query TestOne($someOptionalVar: String) {
foo(someOptionalArg: $someOptionalVar) {
id
name
}
}
```
```graphql
query TestTwo($someOptionalVar: String) {
foo(someOptionalArg: $someOptionalVar) {
id
name
}
}
```
And then `someOptionalVar` is not prefixed if the value is not sent by the user. The batched queries will be sent as below, then it will cause issues.
```graphql
query TestOneTwo($someOptionalVar: String, $someOptionalVar: String) {
_0_foo: foo(someOptionalArg: $someOptionalVar) {
id
name
}
_1_foo: foo(someOptionalArg: $someOptionalVar) {
id
name
}
}
```
## 9.0.7

@@ -4,0 +47,0 @@

14

dist/index.js

@@ -108,7 +108,13 @@ import { getOperationASTFromRequest, relocatedError, fakePromise, mapMaybePromise, isAsyncIterable, memoize2of4 } from '@graphql-tools/utils';

const executionVariableNames = Object.keys(executionVariables);
const hasFragmentDefinitions = request.document.definitions.some(
(def) => isFragmentDefinition(def)
);
let hasFragmentDefinitions = false;
let hasVariables = false;
for (const def of prefixedDocument.definitions) {
if (isFragmentDefinition(def)) {
hasFragmentDefinitions = true;
} else if (isOperationDefinition(def)) {
hasVariables = !!def.variableDefinitions?.length;
}
}
const fragmentSpreadImpl = {};
if (executionVariableNames.length > 0 || hasFragmentDefinitions) {
if (hasVariables || hasFragmentDefinitions) {
prefixedDocument = visit(prefixedDocument, {

@@ -115,0 +121,0 @@ [Kind.VARIABLE]: prefixNode,

{
"name": "@graphql-tools/batch-execute",
"version": "9.0.7",
"version": "9.0.8-alpha-5fb7ce042dd8c2edbe8ba8947d94342a59270992",
"type": "module",

@@ -8,3 +8,3 @@ "description": "A set of utils for faster development of GraphQL tools",

"type": "git",
"url": "graphql-hive/gateway",
"url": "git+https://github.com/graphql-hive/gateway.git",
"directory": "packages/batch-execute"

@@ -11,0 +11,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc