Socket
Socket
Sign inDemoInstall

@graphql-tools/wrap

Package Overview
Dependencies
14
Maintainers
3
Versions
1301
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 10.0.2 to 10.0.3-alpha-20240307135938-3e46cedb52372a41599dee22d230548292d18b8b

35

cjs/transforms/TransformCompositeFields.js

@@ -77,22 +77,15 @@ "use strict";

let newSelections = [];
let typeNameExists = node.selections.some(selection => selection.kind === graphql_1.Kind.FIELD && selection.name.value === '__typename');
let isTypenameSelected = false;
for (const selection of node.selections) {
if (selection.kind !== graphql_1.Kind.FIELD || selection.name.value === '__typename') {
if (selection.kind !== graphql_1.Kind.FIELD) {
newSelections.push(selection);
continue;
}
// The `__typename` selection should not be aliased
// to be accessible with this name
if (selection.name.value === '__typename' &&
(!selection.alias || selection.alias.value === '__typename')) {
isTypenameSelected = true;
}
const newName = selection.name.value;
// See https://github.com/ardatan/graphql-tools/issues/2282
if (!typeNameExists &&
(this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)) {
newSelections.push({
kind: graphql_1.Kind.FIELD,
name: {
kind: graphql_1.Kind.NAME,
value: '__typename',
},
});
typeNameExists = true;
}
let transformedSelection;

@@ -140,2 +133,14 @@ if (this.fieldNodeTransformer == null) {

}
// See https://github.com/ardatan/graphql-tools/issues/2282
if (!isTypenameSelected &&
(this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)) {
newSelections.push({
kind: graphql_1.Kind.FIELD,
name: {
kind: graphql_1.Kind.NAME,
value: '__typename',
},
});
}
return {

@@ -142,0 +147,0 @@ ...node,

@@ -75,22 +75,15 @@ import { Kind, TypeInfo, visit, visitWithTypeInfo, } from 'graphql';

let newSelections = [];
let typeNameExists = node.selections.some(selection => selection.kind === Kind.FIELD && selection.name.value === '__typename');
let isTypenameSelected = false;
for (const selection of node.selections) {
if (selection.kind !== Kind.FIELD || selection.name.value === '__typename') {
if (selection.kind !== Kind.FIELD) {
newSelections.push(selection);
continue;
}
// The `__typename` selection should not be aliased
// to be accessible with this name
if (selection.name.value === '__typename' &&
(!selection.alias || selection.alias.value === '__typename')) {
isTypenameSelected = true;
}
const newName = selection.name.value;
// See https://github.com/ardatan/graphql-tools/issues/2282
if (!typeNameExists &&
(this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)) {
newSelections.push({
kind: Kind.FIELD,
name: {
kind: Kind.NAME,
value: '__typename',
},
});
typeNameExists = true;
}
let transformedSelection;

@@ -138,2 +131,14 @@ if (this.fieldNodeTransformer == null) {

}
// See https://github.com/ardatan/graphql-tools/issues/2282
if (!isTypenameSelected &&
(this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)) {
newSelections.push({
kind: Kind.FIELD,
name: {
kind: Kind.NAME,
value: '__typename',
},
});
}
return {

@@ -140,0 +145,0 @@ ...node,

{
"name": "@graphql-tools/wrap",
"version": "10.0.2",
"version": "10.0.3-alpha-20240307135938-3e46cedb52372a41599dee22d230548292d18b8b",
"description": "A set of utils for faster development of GraphQL tools",

@@ -5,0 +5,0 @@ "sideEffects": false,

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc