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

graphql-anywhere

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-anywhere - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

4

CHANGELOG.md
# Change log
### v0.2.4
- Added support for fragments. If there are multiple fragments in the provided document, the first one is used as the query.
### v0.2.3

@@ -4,0 +8,0 @@

@@ -13,1 +13,2 @@ import { Document, OperationDefinition, FragmentDefinition } from 'graphql';

export declare function addFragmentsToDocument(queryDoc: Document, fragments: FragmentDefinition[]): Document;
export declare function getMainDefinition(queryDoc: Document): OperationDefinition | FragmentDefinition;

@@ -101,2 +101,18 @@ "use strict";

exports.addFragmentsToDocument = addFragmentsToDocument;
function getMainDefinition(queryDoc) {
checkDocument(queryDoc);
try {
return getQueryDefinition(queryDoc);
}
catch (e) {
try {
var fragments = getFragmentDefinitions(queryDoc);
return fragments[0];
}
catch (e) {
throw new Error("Expected a parsed GraphQL query with a query or a fragment.");
}
}
}
exports.getMainDefinition = getMainDefinition;
//# sourceMappingURL=getFromAST.js.map

4

lib/src/index.js

@@ -10,3 +10,3 @@ "use strict";

if (execOptions === void 0) { execOptions = {}; }
var queryDefinition = getFromAST_1.getQueryDefinition(document);
var mainDefinition = getFromAST_1.getMainDefinition(document);
var fragments = getFromAST_1.getFragmentDefinitions(document);

@@ -24,3 +24,3 @@ var fragmentMap = getFromAST_1.createFragmentMap(fragments) || {};

};
return executeSelectionSet(queryDefinition.selectionSet, rootValue, execContext);
return executeSelectionSet(mainDefinition.selectionSet, rootValue, execContext);
}

@@ -27,0 +27,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

{
"name": "graphql-anywhere",
"version": "0.2.3",
"version": "0.2.4",
"description": "Run GraphQL queries with no schema and just one resolver",

@@ -5,0 +5,0 @@ "main": "./lib/src/index.js",

@@ -132,1 +132,17 @@ import {

}
export function getMainDefinition(queryDoc: Document): OperationDefinition | FragmentDefinition {
checkDocument(queryDoc);
try {
return getQueryDefinition(queryDoc);
} catch (e) {
try {
const fragments = getFragmentDefinitions(queryDoc);
return fragments[0];
} catch (e) {
throw new Error(`Expected a parsed GraphQL query with a query or a fragment.`)
}
}
}

@@ -10,3 +10,3 @@ import {

import {
getQueryDefinition,
getMainDefinition,
getFragmentDefinitions,

@@ -81,3 +81,3 @@ createFragmentMap,

) {
const queryDefinition = getQueryDefinition(document);
const mainDefinition = getMainDefinition(document);

@@ -102,3 +102,3 @@ const fragments = getFragmentDefinitions(document);

return executeSelectionSet(
queryDefinition.selectionSet,
mainDefinition.selectionSet,
rootValue,

@@ -105,0 +105,0 @@ execContext

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