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

graphql-mini-transforms

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-mini-transforms - npm Package Compare versions

Comparing version 5.3.3 to 5.3.4

41

build/cjs/document.js

@@ -16,17 +16,14 @@ 'use strict';

}
for (const definition of document.definitions) {
addTypename(definition);
}
const normalizedSource = minifySource(graphql.print(document));
const normalizedDocument = graphql.parse(normalizedSource);
for (const definition of normalizedDocument.definitions) {
stripLoc(definition);
} // This ID is a hash of the full file contents that are part of the document,
}
// This ID is a hash of the full file contents that are part of the document,
// including other documents that are injected in, but excluding any unused
// fragments. This is useful for things like persisted queries.
const id = crypto.createHash('sha256').update(normalizedSource).digest('hex');

@@ -60,3 +57,2 @@ Reflect.defineProperty(normalizedDocument, 'id', {

var _document$loc, _document$loc$source;
return {

@@ -68,13 +64,9 @@ id: document.id,

}
function operationNameForDocument(document) {
var _document$definitions, _document$definitions2;
return (_document$definitions = document.definitions.find(definition => definition.kind === 'OperationDefinition')) === null || _document$definitions === void 0 ? void 0 : (_document$definitions2 = _document$definitions.name) === null || _document$definitions2 === void 0 ? void 0 : _document$definitions2.value;
}
function removeUnusedDefinitions(document) {
const usedDefinitions = new Set();
const dependencies = definitionDependencies(document.definitions);
const markAsUsed = definition => {

@@ -84,5 +76,3 @@ if (usedDefinitions.has(definition)) {

}
usedDefinitions.add(definition);
for (const dependency of dependencies.get(definition) || []) {

@@ -92,3 +82,2 @@ markAsUsed(dependency);

};
for (const definition of document.definitions) {

@@ -99,10 +88,7 @@ if (definition.kind !== 'FragmentDefinition') {

}
document.definitions = [...usedDefinitions];
}
function minifySource(source) {
return source.replace(/#.*/g, '').replace(/\\n/g, ' ').replace(/\s\s+/g, ' ').replace(/\s*({|}|\(|\)|\.|:|,)\s*/g, '$1');
}
function definitionDependencies(definitions) {

@@ -113,11 +99,8 @@ const executableDefinitions = definitions.filter(definition => definition.kind === 'OperationDefinition' || definition.kind === 'FragmentDefinition');

const definition = definitionsByName.get(usedFragment);
if (definition == null) {
throw new Error(`You attempted to use the fragment '${usedFragment}' (in '${executableNode.name ? executableNode.name.value : DEFAULT_NAME}'), but it does not exist. Maybe you forgot to import it from another document?`);
}
return definition;
})]));
}
const TYPENAME_FIELD = {

@@ -131,3 +114,2 @@ kind: 'Field',

};
function addTypename(definition) {

@@ -138,3 +120,2 @@ for (const {

const hasTypename = selections.some(selection => selection.kind === 'Field' && selection.name.value === '__typename');
if (!hasTypename) {

@@ -145,3 +126,2 @@ selections.push(TYPENAME_FIELD);

}
function collectUsedFragmentSpreads(definition, usedSpreads) {

@@ -153,6 +133,4 @@ for (const selection of selectionsForDefinition(definition)) {

}
return usedSpreads;
}
function selectionsForDefinition(definition) {

@@ -162,6 +140,4 @@ if (!('selectionSet' in definition) || definition.selectionSet == null) {

}
return selectionsForSelectionSet(definition.selectionSet);
}
function* selectionSetsForDefinition(definition) {

@@ -171,7 +147,5 @@ if (!('selectionSet' in definition) || definition.selectionSet == null) {

}
if (definition.kind !== 'OperationDefinition') {
yield definition.selectionSet;
}
for (const nestedSelection of selectionsForDefinition(definition)) {

@@ -183,3 +157,2 @@ if ('selectionSet' in nestedSelection && nestedSelection.selectionSet != null) {

}
function* selectionsForSelectionSet({

@@ -190,3 +163,2 @@ selections

yield selection;
if ('selectionSet' in selection && selection.selectionSet != null) {

@@ -197,5 +169,5 @@ yield* selectionsForSelectionSet(selection.selectionSet);

}
function stripDocumentLoc(loc) {
const normalizedLoc = { ...loc
const normalizedLoc = {
...loc
};

@@ -206,3 +178,2 @@ delete normalizedLoc.endToken;

}
function stripLoc(value) {

@@ -215,7 +186,5 @@ if (Array.isArray(value)) {

}
if ('loc' in value) {
delete value.loc;
}
for (const key of Object.keys(value)) {

@@ -222,0 +191,0 @@ stripLoc(value[key]);

@@ -15,3 +15,2 @@ 'use strict';

},
process(rawSource) {

@@ -41,5 +40,4 @@ const {

}
};
exports["default"] = transformer;

@@ -15,3 +15,2 @@ 'use strict';

},
process(rawSource) {

@@ -41,5 +40,4 @@ const {

}
};
exports["default"] = transformer;

@@ -34,3 +34,2 @@ 'use strict';

name: '@shopify/graphql-mini-transforms',
async transform(code, id) {

@@ -41,3 +40,2 @@ if (!id.endsWith('.graphql')) return null;

if (level !== 0) return;
for (const definition of document.definitions) {

@@ -56,6 +54,4 @@ if ('name' in definition && definition.name != null) {

}
};
}
async function loadDocument(code, file, plugin, add, level = 0) {

@@ -68,14 +64,10 @@ const {

add(document$1, level);
if (imports.length === 0) {
return document$1;
}
const resolvedImports = await Promise.all(imports.map(async imported => {
const resolvedId = await plugin.resolve(imported, file);
if (resolvedId == null) {
throw new Error(`Could not find ${JSON.stringify(imported)} from ${JSON.stringify(file)}`);
}
plugin.addWatchFile(resolvedId.id);

@@ -87,3 +79,2 @@ const contents = await fs__namespace.promises.readFile(resolvedId.id, {

}));
for (const {

@@ -94,3 +85,2 @@ definitions

}
return document$1;

@@ -97,0 +87,0 @@ }

3

build/cjs/vite.js

@@ -8,3 +8,4 @@ 'use strict';

function graphql(...args) {
return { ...rollup.graphql(...args),
return {
...rollup.graphql(...args),
enforce: 'pre'

@@ -11,0 +12,0 @@ };

@@ -15,7 +15,5 @@ 'use strict';

} = this.getOptions();
if (done == null) {
throw new Error('@shopify/graphql-loader does not support synchronous processing');
}
try {

@@ -29,3 +27,2 @@ const document$1 = document.cleanDocument(await loadDocument(source, this.context, this));

}
async function loadDocument(rawSource, resolveContext, loader) {

@@ -38,7 +35,5 @@ const normalizedSource = typeof rawSource === 'string' ? rawSource : rawSource.toString();

const document$1 = graphql.parse(source);
if (imports.length === 0) {
return document$1;
}
const resolvedImports = await Promise.all(imports.map(async imported => {

@@ -69,3 +64,2 @@ const resolvedPath = await new Promise((resolve, reject) => {

}));
for (const {

@@ -76,3 +70,2 @@ definitions

}
return document$1;

@@ -79,0 +72,0 @@ }

{
"name": "graphql-mini-transforms",
"version": "5.3.3",
"version": "5.3.4",
"license": "MIT",

@@ -60,3 +60,3 @@ "description": "Transformers for importing .graphql files in various build tools.",

"peerDependencies": {
"rollup": "^3.0.0",
"rollup": "^3.0.0 || ^4.0.0",
"webpack": "^5.38.0"

@@ -63,0 +63,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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