Socket
Socket
Sign inDemoInstall

apollo-utilities

Package Overview
Dependencies
Maintainers
2
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.9 to 1.0.10

1

CHANGELOG.md

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

- Map coverage to original source
- Added ability to include or ignore fragments in `getDirectivesFromDocument` [PR#3010](https://github.com/apollographql/apollo-client/pull/3010)

@@ -8,0 +9,0 @@ ### 1.1.3

5

lib/bundle.umd.js

@@ -675,3 +675,4 @@ (function (global, factory) {

}
function getDirectivesFromDocument(directives, doc) {
function getDirectivesFromDocument(directives, doc, includeAllFragments) {
if (includeAllFragments === void 0) { includeAllFragments = false; }
checkDocument(doc);

@@ -681,3 +682,3 @@ var docClone = cloneDeep(doc);

if ((definition.kind === 'OperationDefinition' ||
definition.kind === 'FragmentDefinition') &&
(definition.kind === 'FragmentDefinition' && !includeAllFragments)) &&
definition.selectionSet) {

@@ -684,0 +685,0 @@ definition.selectionSet = getDirectivesFromSelectionSet(directives, definition.selectionSet);

@@ -14,2 +14,2 @@ import { DocumentNode, DirectiveNode } from 'graphql';

};
export declare function getDirectivesFromDocument(directives: GetDirectiveConfig[], doc: DocumentNode): DocumentNode | null;
export declare function getDirectivesFromDocument(directives: GetDirectiveConfig[], doc: DocumentNode, includeAllFragments?: boolean): DocumentNode | null;

@@ -171,3 +171,4 @@ import { cloneDeep } from './util/cloneDeep';

}
export function getDirectivesFromDocument(directives, doc) {
export function getDirectivesFromDocument(directives, doc, includeAllFragments) {
if (includeAllFragments === void 0) { includeAllFragments = false; }
checkDocument(doc);

@@ -177,3 +178,3 @@ var docClone = cloneDeep(doc);

if ((definition.kind === 'OperationDefinition' ||
definition.kind === 'FragmentDefinition') &&
(definition.kind === 'FragmentDefinition' && !includeAllFragments)) &&
definition.selectionSet) {

@@ -180,0 +181,0 @@ definition.selectionSet = getDirectivesFromSelectionSet(directives, definition.selectionSet);

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

@@ -46,3 +46,3 @@ "author": "James Baxley <james@meteor.com>",

"browserify": "15.2.0",
"flow-bin": "0.64.0",
"flow-bin": "0.67.1",
"graphql": "0.13.1",

@@ -49,0 +49,0 @@ "graphql-tag": "2.8.0",

@@ -885,2 +885,72 @@ import { print } from 'graphql/language/printer';

});
describe('includeAllFragments', () => {
it('= false: should remove the values without a client in fragment', () => {
const query = gql`
fragment client on ClientData {
hi @client
bye @storage
bar
}
query Mixed {
foo @client {
...client
}
bar {
baz
}
}
`;
const expected = gql`
fragment client on ClientData {
hi @client
}
query Mixed {
foo @client {
...client
}
}
`;
const doc = getDirectivesFromDocument([{ name: 'client' }], query, false);
expect(print(doc)).toBe(print(expected));
});
it('= true: should include the values without a client in fragment', () => {
const query = gql`
fragment client on ClientData {
hi @client
bye @storage
bar
}
query Mixed {
foo @client {
...client
}
bar {
baz
}
}
`;
const expected = gql`
fragment client on ClientData {
hi @client
bye @storage
bar
}
query Mixed {
foo @client {
...client
}
}
`;
const doc = getDirectivesFromDocument([{ name: 'client' }], query, true);
expect(print(doc)).toBe(print(expected));
});
});
});

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

throw new Error(
`Argument for the @${
directiveName
} directive must be a variable or a boolean value.`,
`Argument for the @${directiveName} directive must be a variable or a boolean value.`,
);

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

@@ -289,2 +289,3 @@ import {

doc: DocumentNode,
includeAllFragments = false,
): DocumentNode | null {

@@ -296,3 +297,3 @@ checkDocument(doc);

(definition.kind === 'OperationDefinition' ||
definition.kind === 'FragmentDefinition') &&
(definition.kind === 'FragmentDefinition' && !includeAllFragments)) &&
definition.selectionSet

@@ -299,0 +300,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