Socket
Socket
Sign inDemoInstall

apollo-utilities

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-utilities - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change log

### 1.1.1
- Fix typo in error message for invalid argument being passed to @skip or @include directives [PR#2867](https://github.com/apollographql/apollo-client/pull/2867)
### 1.1.0
- update `getStoreKeyName` to support custom directives
### 1.0.5

@@ -8,0 +14,0 @@ - package dependency updates

20

lib/bundle.umd.js

@@ -93,2 +93,3 @@ (function (global, factory) {

}
var KNOWN_DIRECTIVES = ['connection', 'include', 'skip'];
function getStoreKeyName(fieldName, args, directives) {

@@ -115,7 +116,20 @@ if (directives &&

}
var completeFieldName = fieldName;
if (args) {
var stringifiedArgs = JSON.stringify(args);
return fieldName + "(" + stringifiedArgs + ")";
completeFieldName += "(" + stringifiedArgs + ")";
}
return fieldName;
if (directives) {
Object.keys(directives).forEach(function (key) {
if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
return;
if (directives[key] && Object.keys(directives[key]).length) {
completeFieldName += "@" + key + "(" + JSON.stringify(directives[key]) + ")";
}
else {
completeFieldName += "@" + key;
}
});
}
return completeFieldName;
}

@@ -220,3 +234,3 @@ function argumentsObjectFromField(field, variables) {

if (ifValue.kind !== 'Variable') {
throw new Error("Argument for the @" + directiveName + " directive must be a variable or a bool ean value.");
throw new Error("Argument for the @" + directiveName + " directive must be a variable or a boolean value.");
}

@@ -223,0 +237,0 @@ else {

2

lib/directives.js

@@ -35,3 +35,3 @@ import { argumentsObjectFromField } from './storeUtils';

if (ifValue.kind !== 'Variable') {
throw new Error("Argument for the @" + directiveName + " directive must be a variable or a bool ean value.");
throw new Error("Argument for the @" + directiveName + " directive must be a variable or a boolean value.");
}

@@ -38,0 +38,0 @@ else {

@@ -87,2 +87,3 @@ export function isScalarValue(value) {

}
var KNOWN_DIRECTIVES = ['connection', 'include', 'skip'];
export function getStoreKeyName(fieldName, args, directives) {

@@ -109,7 +110,20 @@ if (directives &&

}
var completeFieldName = fieldName;
if (args) {
var stringifiedArgs = JSON.stringify(args);
return fieldName + "(" + stringifiedArgs + ")";
completeFieldName += "(" + stringifiedArgs + ")";
}
return fieldName;
if (directives) {
Object.keys(directives).forEach(function (key) {
if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
return;
if (directives[key] && Object.keys(directives[key]).length) {
completeFieldName += "@" + key + "(" + JSON.stringify(directives[key]) + ")";
}
else {
completeFieldName += "@" + key;
}
});
}
return completeFieldName;
}

@@ -116,0 +130,0 @@ export function argumentsObjectFromField(field, variables) {

{
"name": "apollo-utilities",
"version": "1.0.4",
"version": "1.0.5",
"description": "Utilities for working with GraphQL ASTs",

@@ -42,8 +42,8 @@ "author": "James Baxley <james@meteor.com>",

"devDependencies": {
"@types/graphql": "0.11.7",
"@types/graphql": "0.12.3",
"@types/jest": "21.1.10",
"@types/lodash": "4.14.92",
"@types/node": "8.5.5",
"browserify": "15.0.0",
"flow-bin": "0.62.0",
"@types/lodash": "4.14.97",
"@types/node": "8.5.9",
"browserify": "15.2.0",
"flow-bin": "0.64.0",
"graphql": "0.12.3",

@@ -54,5 +54,5 @@ "graphql-tag": "2.6.1",

"rimraf": "2.6.2",
"rollup": "0.53.3",
"rollup": "0.55.1",
"ts-jest": "20.0.14",
"tslint": "5.8.0",
"tslint": "5.9.1",
"typescript": "2.5.2",

@@ -59,0 +59,0 @@ "uglifyjs": "2.4.11"

@@ -74,3 +74,3 @@ // Provides the methods that allow QueryManager to handle

directiveName
} directive must be a variable or a bool ean value.`,
} directive must be a variable or a boolean value.`,
);

@@ -77,0 +77,0 @@ } else {

@@ -167,2 +167,4 @@ import {

const KNOWN_DIRECTIVES: string[] = ['connection', 'include', 'skip'];
export function getStoreKeyName(

@@ -201,9 +203,21 @@ fieldName: string,

let completeFieldName: string = fieldName;
if (args) {
const stringifiedArgs: string = JSON.stringify(args);
completeFieldName += `(${stringifiedArgs})`;
}
return `${fieldName}(${stringifiedArgs})`;
if (directives) {
Object.keys(directives).forEach(key => {
if (KNOWN_DIRECTIVES.indexOf(key) !== -1) return;
if (directives[key] && Object.keys(directives[key]).length) {
completeFieldName += `@${key}(${JSON.stringify(directives[key])})`;
} else {
completeFieldName += `@${key}`;
}
});
}
return fieldName;
return completeFieldName;
}

@@ -210,0 +224,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

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