@apollo-elements/lib
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -6,2 +6,19 @@ # Change Log | ||
# [3.4.0](https://github.com/apollo-elements/apollo-elements/compare/@apollo-elements/lib@3.3.0...@apollo-elements/lib@3.4.0) (2020-11-22) | ||
### Bug Fixes | ||
* **components:** bug fixes ([57c53b8](https://github.com/apollo-elements/apollo-elements/commit/57c53b84fa430b1001c63ab1443c84b151b38680)) | ||
* **lib:** use interfaces element class ([f961707](https://github.com/apollo-elements/apollo-elements/commit/f9617076083a24637b9e1c0d6f2fe67f1bf9b20c)) | ||
### Features | ||
* **lib:** move hybrids/prototype to lib ([839e9f1](https://github.com/apollo-elements/apollo-elements/commit/839e9f10f5d46d520a63d698d7105abcf0ac8cc3)) | ||
# [3.3.0](https://github.com/apollo-elements/apollo-elements/compare/@apollo-elements/lib@3.2.0...@apollo-elements/lib@3.3.0) (2020-10-25) | ||
@@ -8,0 +25,0 @@ |
import { ApolloClient, ApolloLink, HttpLink, InMemoryCache, } from '@apollo/client/core'; | ||
import { hasAllVariables } from './has-all-variables'; | ||
const validateVariablesLink = new ApolloLink((operation, forward) => hasAllVariables(operation) && forward(operation)); | ||
const validateVariablesLink = new ApolloLink((operation, forward) => hasAllVariables(operation) && forward(operation)); /* c8 ignore next */ // this is called | ||
/** | ||
@@ -5,0 +5,0 @@ * Creates a simple ApolloClient |
@@ -22,3 +22,3 @@ import { | ||
new ApolloLink((operation, forward) => | ||
hasAllVariables(operation) && forward(operation)); | ||
hasAllVariables(operation) && forward(operation)); /* c8 ignore next */ // this is called | ||
@@ -25,0 +25,0 @@ /** |
@@ -38,3 +38,3 @@ /** isOperationDefinition :: DefinitionNode -> Boolean */ | ||
.map(hasNonNullValue(operation.variables)) | ||
.every(isTrue); | ||
.every(isTrue); /* c8 ignore next */ // this is covered | ||
} | ||
@@ -41,0 +41,0 @@ catch { |
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
import { hasAllVariables } from './has-all-variables'; | ||
@@ -91,2 +91,15 @@ function pass(description, operation) { | ||
}); | ||
describe('for two nullable and two non-nullable variables', function () { | ||
const query = gql `query OptOneNeedsOne($one: ID, $two: ID, $three: ID!, $four: ID!) { q(one: $one, two: $two, three: $three, four: $four) { one two three four } }`; | ||
pass('with al variables', { query, variables: { one: '1', two: '2', three: '3', four: '4' } }); | ||
pass(`with first two variable null and last two variables set`, { query, variables: { one: null, two: null, three: '3', four: '4' } }); | ||
pass('with last two variable only', { query, variables: { three: '3', four: '4' } }); | ||
fail('with no variables', { query, variables: {} }); | ||
fail('with first two variables null', { query, variables: { one: null, two: null } }); | ||
fail('with first variable only', { query, variables: { one: '1' } }); | ||
fail('with first variable only null', { query, variables: { one: null } }); | ||
fail('with second variable only null', { query, variables: { two: null } }); | ||
fail(`with second variable null and first variable`, { query, variables: { one: '1', two: null } }); | ||
fail('with third variable only', { query, variables: { three: '3' } }); | ||
}); | ||
it('handles weird input', function () { | ||
@@ -93,0 +106,0 @@ // @ts-expect-error: testing weird input |
import type { Operation } from '@apollo/client/core'; | ||
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
import { hasAllVariables } from './has-all-variables'; | ||
@@ -110,2 +111,17 @@ | ||
describe('for two nullable and two non-nullable variables', function() { | ||
const query = gql`query OptOneNeedsOne($one: ID, $two: ID, $three: ID!, $four: ID!) { q(one: $one, two: $two, three: $three, four: $four) { one two three four } }`; | ||
pass('with al variables', { query, variables: { one: '1', two: '2', three: '3', four: '4' } }); | ||
pass(`with first two variable null and last two variables set`, { query, variables: { one: null, two: null, three: '3', four: '4' } }); | ||
pass('with last two variable only', { query, variables: { three: '3', four: '4' } }); | ||
fail('with no variables', { query, variables: {} }); | ||
fail('with first two variables null', { query, variables: { one: null, two: null } }); | ||
fail('with first variable only', { query, variables: { one: '1' } }); | ||
fail('with first variable only null', { query, variables: { one: null } }); | ||
fail('with second variable only null', { query, variables: { two: null } }); | ||
fail(`with second variable null and first variable`, { query, variables: { one: '1', two: null } }); | ||
fail('with third variable only', { query, variables: { three: '3' } }); | ||
}); | ||
it('handles weird input', function() { | ||
@@ -112,0 +128,0 @@ // @ts-expect-error: testing weird input |
@@ -47,3 +47,3 @@ import type { DefinitionNode, OperationDefinitionNode, VariableDefinitionNode } from 'graphql'; | ||
.map(hasNonNullValue(operation.variables)) | ||
.every(isTrue); | ||
.every(isTrue); /* c8 ignore next */ // this is covered | ||
} catch { | ||
@@ -50,0 +50,0 @@ return false; |
export declare function stripUndefinedValues<X>(o: X): X; | ||
/** Splits a string by `,` then trims each of the results */ | ||
export declare function splitCommasAndTrim(value: string): string[]; | ||
export declare function isEmpty(x: object | Array<unknown>): boolean; |
@@ -12,2 +12,7 @@ const valueIsDefined = ([, v]) => v !== undefined; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function isEmpty(x) { | ||
const { length } = Array.isArray(x) ? x : Object.keys(x); | ||
return !length; | ||
} | ||
//# sourceMappingURL=helpers.js.map |
@@ -15,1 +15,7 @@ const valueIsDefined = | ||
} | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function isEmpty(x: object | Array<unknown>): boolean { | ||
const { length } = Array.isArray(x) ? x : Object.keys(x); | ||
return !length; | ||
} |
@@ -17,9 +17,9 @@ import { hasDirectives } from '@apollo/client/utilities'; | ||
const definitions = ((_a = query === null || query === void 0 ? void 0 : query.definitions) !== null && _a !== void 0 ? _a : []); | ||
if (!hasDirectives(['client'], query)) | ||
return false; | ||
if (!hasDirectives(['client'], query)) /* c8 ignore next */ // this is covered | ||
return false; /* c8 ignore next */ | ||
return definitions.reduce((acc, definition) => { | ||
var _a, _b; | ||
const selections = (_b = (_a = definition === null || definition === void 0 ? void 0 : definition.selectionSet) === null || _a === void 0 ? void 0 : _a.selections) !== null && _b !== void 0 ? _b : []; | ||
if (!isOperationDefinition(definition)) | ||
return acc && true; | ||
if (!isOperationDefinition(definition)) /* c8 ignore next */ // this is a typeguard, basically | ||
return acc && true; /* c8 ignore next */ | ||
else if (definition.directives.length && definition.directives.every(isClientDirective)) | ||
@@ -26,0 +26,0 @@ return acc && true; |
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
import { isClientOperation } from './is-client-operation'; | ||
@@ -4,0 +4,0 @@ import { createOperation } from '@apollo/client/link/utils'; |
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
@@ -4,0 +4,0 @@ import { isClientOperation } from './is-client-operation'; |
@@ -38,4 +38,4 @@ import type { Operation } from '@apollo/client/core'; | ||
if (!hasDirectives(['client'], query)) | ||
return false; | ||
if (!hasDirectives(['client'], query)) /* c8 ignore next */ // this is covered | ||
return false; /* c8 ignore next */ | ||
@@ -48,4 +48,4 @@ return definitions.reduce((acc, definition) => { | ||
if (!isOperationDefinition(definition)) | ||
return acc && true; | ||
if (!isOperationDefinition(definition)) /* c8 ignore next */ // this is a typeguard, basically | ||
return acc && true; /* c8 ignore next */ | ||
@@ -52,0 +52,0 @@ else if (definition.directives.length && definition.directives.every(isClientDirective)) |
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
import { isValidGql } from './is-valid-gql'; | ||
@@ -4,0 +4,0 @@ const simpleValid = gql ` |
import { expect } from '@open-wc/testing'; | ||
import gql from 'graphql-tag'; | ||
import { gql } from '@apollo/client/core'; | ||
@@ -4,0 +4,0 @@ import { isValidGql } from './is-valid-gql'; |
{ | ||
"name": "@apollo-elements/lib", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "Library functions for apollo-elements", | ||
@@ -10,2 +10,3 @@ "main": "index.js", | ||
"exports": [ | ||
"./escape.js", | ||
"./index.js", | ||
@@ -48,5 +49,5 @@ "./helpers.js", | ||
"graphql-tag": "^2.11.0", | ||
"tslib": "^2.0.1" | ||
"tslib": "^2.0.3" | ||
}, | ||
"gitHead": "87b018f7d76920263a1b92ed90493806ccaf0344" | ||
"gitHead": "6fe55e2334c655041f573d4f5c24ae2185029356" | ||
} |
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
101724
61
1476
Updatedtslib@^2.0.3