apollo-utilities
Advanced tools
Comparing version
@@ -333,3 +333,3 @@ exports.__esModule = true; | ||
evaledValue = variables[ifArgument.value.name.value]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(evaledValue !== void 0, 1) : (0, _tsInvariant.invariant)(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(evaledValue !== void 0, 13) : (0, _tsInvariant.invariant)(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
} else { | ||
@@ -372,7 +372,7 @@ evaledValue = ifArgument.value.value; | ||
var directiveName = directive.name.value; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, 2) : (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, 14) : (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
var ifArgument = directiveArguments[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', 3) : (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', 15) : (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
var ifValue = ifArgument.value; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 4) : (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 16) : (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value."); | ||
return { | ||
@@ -390,3 +390,3 @@ directive: directive, | ||
if (definition.kind === 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(5) : new _tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + 'No operations are allowed when using a fragment as a query. Only fragments are allowed.'); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(11) : new _tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + 'No operations are allowed when using a fragment as a query. Only fragments are allowed.'); | ||
} | ||
@@ -400,3 +400,3 @@ | ||
if (typeof actualFragmentName === 'undefined') { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragments.length === 1, 6) : (0, _tsInvariant.invariant)(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragments.length === 1, 12) : (0, _tsInvariant.invariant)(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
actualFragmentName = fragments[0].name.value; | ||
@@ -448,3 +448,3 @@ } | ||
})[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(mutationDef, 7) : (0, _tsInvariant.invariant)(mutationDef, 'Must contain a mutation definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(mutationDef, 1) : (0, _tsInvariant.invariant)(mutationDef, 'Must contain a mutation definition.'); | ||
return mutationDef; | ||
@@ -454,3 +454,3 @@ } | ||
function checkDocument(doc) { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', 8) : (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', 2) : (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
var operations = doc.definitions.filter(function (d) { | ||
@@ -460,3 +460,3 @@ return d.kind !== 'FragmentDefinition'; | ||
if (definition.kind !== 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(9) : new _tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(3) : new _tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
} | ||
@@ -466,3 +466,3 @@ | ||
}); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(operations.length <= 1, 10) : (0, _tsInvariant.invariant)(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(operations.length <= 1, 4) : (0, _tsInvariant.invariant)(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
return doc; | ||
@@ -480,3 +480,3 @@ } | ||
var def = getOperationDefinition(document); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(def, 11) : (0, _tsInvariant.invariant)(def, "GraphQL document is missing an operation"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(def, 5) : (0, _tsInvariant.invariant)(def, "GraphQL document is missing an operation"); | ||
return def; | ||
@@ -501,3 +501,3 @@ } | ||
var queryDef = getOperationDefinition(doc); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 12) : (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 6) : (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
return queryDef; | ||
@@ -507,6 +507,6 @@ } | ||
function getFragmentDefinition(doc) { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.kind === 'Document', 13) : (0, _tsInvariant.invariant)(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 14) : (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.kind === 'Document', 7) : (0, _tsInvariant.invariant)(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 8) : (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
var fragmentDef = doc.definitions[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 15) : (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 9) : (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
return fragmentDef; | ||
@@ -539,3 +539,3 @@ } | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(16) : new _tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(10) : new _tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
} | ||
@@ -542,0 +542,0 @@ |
@@ -1,1 +0,1 @@ | ||
exports.__esModule=!0,exports.addTypenameToDocument=function(e){return(0,n.visit)(y(e),{SelectionSet:{enter:function(e,n,t){if(!t||"OperationDefinition"!==t.kind){var i=e.selections;if(i){var o=i.some(function(e){return f(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))});if(!o){var a=t;if(!(f(a)&&a.directives&&a.directives.some(function(e){return"export"===e.name.value})))return(0,r.__assign)((0,r.__assign)({},e),{selections:(0,r.__spreadArrays)(i,[_])})}}}}}})},exports.argumentsObjectFromField=s,exports.assign=x,exports.buildQueryFromSelectionSet=function(e){if("query"===k(e).operation)return e;return(0,n.visit)(e,{OperationDefinition:{enter:function(e){return(0,r.__assign)((0,r.__assign)({},e),{operation:"query"})}}})},exports.checkDocument=y,exports.cloneDeep=function(e){return function e(n,t){switch(M.call(n)){case"[object Array]":if(t.has(n))return t.get(n);var r=n.slice(0);return t.set(n,r),r.forEach(function(n,i){r[i]=e(n,t)}),r;case"[object Object]":if(t.has(n))return t.get(n);var i=Object.create(Object.getPrototypeOf(n));return t.set(n,i),Object.keys(n).forEach(function(r){i[r]=e(n[r],t)}),i;default:return n}}(e,new Map)},exports.createFragmentMap=O,exports.getDefaultValues=function(e){if(e&&e.variableDefinitions&&e.variableDefinitions.length){var n=e.variableDefinitions.filter(function(e){var n=e.defaultValue;return n}).map(function(e){var n=e.variable,t=e.defaultValue,r={};return a(r,n.name,t),r});return x.apply(void 0,(0,r.__spreadArrays)([{}],n))}return{}},exports.getDirectiveInfoFromField=function(e,n){if(e.directives&&e.directives.length){var t={};return e.directives.forEach(function(e){t[e.name.value]=s(e,n)}),t}return null},exports.getDirectiveNames=m,exports.getDirectivesFromDocument=function(e,t){var i;return y(t),E((0,n.visit)(t,{SelectionSet:{enter:function(n,t,o,a){var u=a.join("-");if(!i||u===i||!u.startsWith(i)){if(n.selections){var c=n.selections.filter(function(n){return I(e,n)});return w(e,n,!1)&&(i=u),(0,r.__assign)((0,r.__assign)({},n),{selections:c})}return null}}}}))},exports.getEnv=J,exports.getFragmentDefinition=D,exports.getFragmentDefinitions=b,exports.getFragmentQueryDocument=function(e,n){var i=n,o=[];e.definitions.forEach(function(e){if("OperationDefinition"===e.kind)throw new t.InvariantError(5);"FragmentDefinition"===e.kind&&o.push(e)}),void 0===i&&((0,t.invariant)(1===o.length,6),i=o[0].name.value);return(0,r.__assign)((0,r.__assign)({},e),{definitions:(0,r.__spreadArrays)([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:i}}]}}],e.definitions)})},exports.getInclusionDirectives=g,exports.getMainDefinition=k,exports.getMutationDefinition=function(e){y(e);var n=e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})[0];return(0,t.invariant)(n,7),n},exports.getOperationDefinition=h,exports.getOperationDefinitionOrDie=function(e){var n=h(e);return(0,t.invariant)(n,11),n},exports.getOperationName=function(e){return e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&e.name}).map(function(e){return e.name.value})[0]||null},exports.getQueryDefinition=function(e){var n=h(e);return(0,t.invariant)(n&&"query"===n.operation,12),n},exports.getStoreKeyName=c,exports.graphQLResultHasError=function(e){return e.errors&&e.errors.length},exports.hasClientExports=function(e){return e&&p(["client"],e)&&p(["export"],e)},exports.hasDirectives=p,exports.isDevelopment=Q,exports.isEnv=P,exports.isField=f,exports.isIdValue=function(e){return e&&"id"===e.type&&"boolean"==typeof e.generated},exports.isInlineFragment=l,exports.isJsonValue=function(e){return null!=e&&"object"==typeof e&&"json"===e.type},exports.isNumberValue=function(e){return["IntValue","FloatValue"].indexOf(e.kind)>-1},exports.isProduction=L,exports.isScalarValue=function(e){return["StringValue","BooleanValue","EnumValue"].indexOf(e.kind)>-1},exports.isTest=T,exports.maybeDeepFreeze=function(e){if(Q()||T()){var n="function"==typeof Symbol&&"string"==typeof Symbol("");if(!n)return function e(n){Object.freeze(n);Object.getOwnPropertyNames(n).forEach(function(t){null===n[t]||"object"!=typeof n[t]&&"function"!=typeof n[t]||Object.isFrozen(n[t])||e(n[t])});return n}(e)}return e},exports.mergeDeep=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return z(e)},exports.mergeDeepArray=z,exports.removeArgumentsFromDocument=N,exports.removeClientSetsFromDocument=function(e){y(e);var t=V([{test:function(e){return"client"===e.name.value},remove:!0}],e);t&&(t=(0,n.visit)(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet){var n=e.selectionSet.selections.every(function(e){return f(e)&&"__typename"===e.name.value});if(n)return null}}}}));return t},exports.removeConnectionDirectiveFromDocument=function(e){return V([j],y(e))},exports.removeDirectivesFromDocument=V,exports.removeFragmentSpreadFromDocument=q,exports.resultKeyNameFromField=function(e){return e.alias?e.alias.value:e.name.value},exports.shouldInclude=function(e,n){void 0===n&&(n={});return g(e.directives).every(function(e){var r=e.directive,i=e.ifArgument,o=!1;return"Variable"===i.value.kind?(o=n[i.value.name.value],(0,t.invariant)(void 0!==o,1)):o=i.value.value,"skip"===r.name.value?!o:o})},exports.storeKeyNameFromField=function(e,n){var t=null;e.directives&&(t={},e.directives.forEach(function(e){t[e.name.value]={},e.arguments&&e.arguments.forEach(function(r){var i=r.name,o=r.value;return a(t[e.name.value],i,o,n)})}));var r=null;e.arguments&&e.arguments.length&&(r={},e.arguments.forEach(function(e){var t=e.name,i=e.value;return a(r,t,i,n)}));return c(e.name.value,r,t)},exports.stripSymbols=function(e){return JSON.parse(JSON.stringify(e))},exports.toIdValue=function(e,n){void 0===n&&(n=!1);return(0,r.__assign)({type:"id",generated:n},"string"==typeof e?{id:e,typename:void 0}:e)},exports.tryFunctionOrLogError=function(e){try{return e()}catch(e){console.error&&console.error(e)}},exports.valueFromNode=function e(n,t){void 0===t&&(t=v);switch(n.kind){case"Variable":return t(n);case"NullValue":return null;case"IntValue":return parseInt(n.value,10);case"FloatValue":return parseFloat(n.value);case"ListValue":return n.values.map(function(n){return e(n,t)});case"ObjectValue":for(var r={},i=0,o=n.fields;i<o.length;i++){var a=o[i];r[a.name.value]=e(a.value,t)}return r;default:return n.value}},exports.valueToObjectRepresentation=a,exports.variablesInOperation=function(e){var n=new Set;if(e.variableDefinitions)for(var t=0,r=e.variableDefinitions;t<r.length;t++){var i=r[t];n.add(i.variable.name.value)}return n},exports.warnOnceInDevelopment=function(e,n){void 0===n&&(n="warn");L()||R[e]||(T()||(R[e]=!0),"error"===n?console.error(e):console.warn(e))},exports.canUseWeakMap=exports.isEqual=void 0;var e,n=require("graphql/language/visitor"),t=require("ts-invariant"),r=require("tslib"),i=(e=require("fast-json-stable-stringify"))&&e.__esModule?e:{default:e},o=require("@wry/equality");function a(e,n,r,i){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[n.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[n.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var o={};r.fields.map(function(e){return a(o,e.name,e.value,i)}),e[n.value]=o}else if(function(e){return"Variable"===e.kind}(r)){var u=(i||{})[r.name.value];e[n.value]=u}else if(function(e){return"ListValue"===e.kind}(r))e[n.value]=r.values.map(function(e){var t={};return a(t,n,e,i),t[n.value]});else if(function(e){return"EnumValue"===e.kind}(r))e[n.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw new t.InvariantError(17);e[n.value]=null}}exports.isEqual=o.equal;var u=["connection","include","skip","client","rest","export"];function c(e,n,t){if(t&&t.connection&&t.connection.key){if(t.connection.filter&&t.connection.filter.length>0){var r=t.connection.filter?t.connection.filter:[];r.sort();var o=n,a={};return r.forEach(function(e){a[e]=o[e]}),t.connection.key+"("+JSON.stringify(a)+")"}return t.connection.key}var c=e;if(n){var s=(0,i.default)(n);c+="("+s+")"}return t&&Object.keys(t).forEach(function(e){-1===u.indexOf(e)&&(t[e]&&Object.keys(t[e]).length?c+="@"+e+"("+JSON.stringify(t[e])+")":c+="@"+e)}),c}function s(e,n){if(e.arguments&&e.arguments.length){var t={};return e.arguments.forEach(function(e){var r=e.name,i=e.value;return a(t,r,i,n)}),t}return null}function f(e){return"Field"===e.kind}function l(e){return"InlineFragment"===e.kind}function v(e){throw new t.InvariantError(18)}function m(e){var t=[];return(0,n.visit)(e,{Directive:function(e){t.push(e.name.value)}}),t}function p(e,n){return m(n).some(function(n){return e.indexOf(n)>-1})}function d(e){var n=e.name.value;return"skip"===n||"include"===n}function g(e){return e?e.filter(d).map(function(e){var n=e.arguments;e.name.value;(0,t.invariant)(n&&1===n.length,2);var r=n[0];(0,t.invariant)(r.name&&"if"===r.name.value,3);var i=r.value;return(0,t.invariant)(i&&("Variable"===i.kind||"BooleanValue"===i.kind),4),{directive:e,ifArgument:r}}):[]}function x(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.forEach(function(n){null!=n&&Object.keys(n).forEach(function(t){e[t]=n[t]})}),e}function y(e){(0,t.invariant)(e&&"Document"===e.kind,8);var n=e.definitions.filter(function(e){return"FragmentDefinition"!==e.kind}).map(function(e){if("OperationDefinition"!==e.kind)throw new t.InvariantError(9);return e});return(0,t.invariant)(n.length<=1,10),e}function h(e){return y(e),e.definitions.filter(function(e){return"OperationDefinition"===e.kind})[0]}function b(e){return e.definitions.filter(function(e){return"FragmentDefinition"===e.kind})}function D(e){(0,t.invariant)("Document"===e.kind,13),(0,t.invariant)(e.definitions.length<=1,14);var n=e.definitions[0];return(0,t.invariant)("FragmentDefinition"===n.kind,15),n}function k(e){var n;y(e);for(var r=0,i=e.definitions;r<i.length;r++){var o=i[r];if("OperationDefinition"===o.kind){var a=o.operation;if("query"===a||"mutation"===a||"subscription"===a)return o}"FragmentDefinition"!==o.kind||n||(n=o)}if(n)return n;throw new t.InvariantError(16)}function O(e){void 0===e&&(e=[]);var n={};return e.forEach(function(e){n[e.name.value]=e}),n}function F(e,n,t){var r=0;return e.forEach(function(t,i){n.call(this,t,i,e)&&(e[r++]=t)},t),e.length=r,e}var _={kind:"Field",name:{kind:"Name",value:"__typename"}};function E(e){return function e(n,t){return n.selectionSet.selections.every(function(n){return"FragmentSpread"===n.kind&&e(t[n.name.value],t)})}(h(e)||D(e),O(b(e)))?null:e}function S(e){return function(n){return e.some(function(e){return e.name&&e.name===n.name.value||e.test&&e.test(n)})}}function V(e,t){var r=Object.create(null),i=[],o=Object.create(null),a=[],u=E((0,n.visit)(t,{Variable:{enter:function(e,n,t){"VariableDefinition"!==t.kind&&(r[e.name.value]=!0)}},Field:{enter:function(n){if(e&&n.directives&&(e.some(function(e){return e.remove})&&n.directives&&n.directives.some(S(e))))return n.arguments&&n.arguments.forEach(function(e){"Variable"===e.value.kind&&i.push({name:e.value.name.value})}),n.selectionSet&&function e(n){var t=[];n.selections.forEach(function(n){(f(n)||l(n))&&n.selectionSet?e(n.selectionSet).forEach(function(e){return t.push(e)}):"FragmentSpread"===n.kind&&t.push(n)});return t}(n.selectionSet).forEach(function(e){a.push({name:e.name.value})}),null}},FragmentSpread:{enter:function(e){o[e.name.value]=!0}},Directive:{enter:function(n){if(S(e)(n))return null}}}));return u&&F(i,function(e){return!r[e.name]}).length&&(u=N(i,u)),u&&F(a,function(e){return!o[e.name]}).length&&(u=q(a,u)),u}var j={test:function(e){var n="connection"===e.name.value;return n&&(!e.arguments||e.arguments.some(function(e){return"key"===e.name.value})),n}};function w(e,n,t){return void 0===t&&(t=!0),n&&n.selections&&n.selections.some(function(n){return I(e,n,t)})}function I(e,n,t){return void 0===t&&(t=!0),!f(n)||!!n.directives&&(n.directives.some(S(e))||t&&w(e,n.selectionSet,t))}function N(e,t){var i=function(e){return function(n){return e.some(function(e){return n.value&&"Variable"===n.value.kind&&n.value.name&&(e.name===n.value.name.value||e.test&&e.test(n))})}}(e);return E((0,n.visit)(t,{OperationDefinition:{enter:function(n){return(0,r.__assign)((0,r.__assign)({},n),{variableDefinitions:n.variableDefinitions.filter(function(n){return!e.some(function(e){return e.name===n.variable.name.value})})})}},Field:{enter:function(n){if(e.some(function(e){return e.remove})){var t=0;if(n.arguments.forEach(function(e){i(e)&&(t+=1)}),1===t)return null}}},Argument:{enter:function(e){if(i(e))return null}}}))}function q(e,t){function r(n){if(e.some(function(e){return e.name===n.name.value}))return null}return E((0,n.visit)(t,{FragmentSpread:{enter:r},FragmentDefinition:{enter:r}}))}var A="function"==typeof WeakMap&&!("object"==typeof navigator&&"ReactNative"===navigator.product);exports.canUseWeakMap=A;var M=Object.prototype.toString;function J(){return"undefined"!=typeof process?"production":"development"}function P(e){return J()===e}function L(){return!0===P("production")}function Q(){return!0===P("development")}function T(){return!0===P("test")}var W=Object.prototype.hasOwnProperty;function z(e){var n=e[0]||{},t=e.length;if(t>1){var r=[];n=K(n,r);for(var i=1;i<t;++i)n=C(n,e[i],r)}return n}function B(e){return null!==e&&"object"==typeof e}function C(e,n,t){return B(n)&&B(e)?(Object.isExtensible&&!Object.isExtensible(e)&&(e=K(e,t)),Object.keys(n).forEach(function(r){var i=n[r];if(W.call(e,r)){var o=e[r];i!==o&&(e[r]=C(K(o,t),i,t))}else e[r]=i}),e):n}function K(e,n){return null!==e&&"object"==typeof e&&n.indexOf(e)<0&&(e=Array.isArray(e)?e.slice(0):(0,r.__assign)({__proto__:Object.getPrototypeOf(e)},e),n.push(e)),e}var R=Object.create({}); | ||
exports.__esModule=!0,exports.addTypenameToDocument=function(e){return(0,n.visit)(y(e),{SelectionSet:{enter:function(e,n,t){if(!t||"OperationDefinition"!==t.kind){var i=e.selections;if(i){var o=i.some(function(e){return f(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))});if(!o){var a=t;if(!(f(a)&&a.directives&&a.directives.some(function(e){return"export"===e.name.value})))return(0,r.__assign)((0,r.__assign)({},e),{selections:(0,r.__spreadArrays)(i,[_])})}}}}}})},exports.argumentsObjectFromField=s,exports.assign=x,exports.buildQueryFromSelectionSet=function(e){if("query"===k(e).operation)return e;return(0,n.visit)(e,{OperationDefinition:{enter:function(e){return(0,r.__assign)((0,r.__assign)({},e),{operation:"query"})}}})},exports.checkDocument=y,exports.cloneDeep=function(e){return function e(n,t){switch(M.call(n)){case"[object Array]":if(t.has(n))return t.get(n);var r=n.slice(0);return t.set(n,r),r.forEach(function(n,i){r[i]=e(n,t)}),r;case"[object Object]":if(t.has(n))return t.get(n);var i=Object.create(Object.getPrototypeOf(n));return t.set(n,i),Object.keys(n).forEach(function(r){i[r]=e(n[r],t)}),i;default:return n}}(e,new Map)},exports.createFragmentMap=O,exports.getDefaultValues=function(e){if(e&&e.variableDefinitions&&e.variableDefinitions.length){var n=e.variableDefinitions.filter(function(e){var n=e.defaultValue;return n}).map(function(e){var n=e.variable,t=e.defaultValue,r={};return a(r,n.name,t),r});return x.apply(void 0,(0,r.__spreadArrays)([{}],n))}return{}},exports.getDirectiveInfoFromField=function(e,n){if(e.directives&&e.directives.length){var t={};return e.directives.forEach(function(e){t[e.name.value]=s(e,n)}),t}return null},exports.getDirectiveNames=m,exports.getDirectivesFromDocument=function(e,t){var i;return y(t),E((0,n.visit)(t,{SelectionSet:{enter:function(n,t,o,a){var u=a.join("-");if(!i||u===i||!u.startsWith(i)){if(n.selections){var c=n.selections.filter(function(n){return I(e,n)});return w(e,n,!1)&&(i=u),(0,r.__assign)((0,r.__assign)({},n),{selections:c})}return null}}}}))},exports.getEnv=J,exports.getFragmentDefinition=D,exports.getFragmentDefinitions=b,exports.getFragmentQueryDocument=function(e,n){var i=n,o=[];e.definitions.forEach(function(e){if("OperationDefinition"===e.kind)throw new t.InvariantError(11);"FragmentDefinition"===e.kind&&o.push(e)}),void 0===i&&((0,t.invariant)(1===o.length,12),i=o[0].name.value);return(0,r.__assign)((0,r.__assign)({},e),{definitions:(0,r.__spreadArrays)([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:i}}]}}],e.definitions)})},exports.getInclusionDirectives=g,exports.getMainDefinition=k,exports.getMutationDefinition=function(e){y(e);var n=e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})[0];return(0,t.invariant)(n,1),n},exports.getOperationDefinition=h,exports.getOperationDefinitionOrDie=function(e){var n=h(e);return(0,t.invariant)(n,5),n},exports.getOperationName=function(e){return e.definitions.filter(function(e){return"OperationDefinition"===e.kind&&e.name}).map(function(e){return e.name.value})[0]||null},exports.getQueryDefinition=function(e){var n=h(e);return(0,t.invariant)(n&&"query"===n.operation,6),n},exports.getStoreKeyName=c,exports.graphQLResultHasError=function(e){return e.errors&&e.errors.length},exports.hasClientExports=function(e){return e&&p(["client"],e)&&p(["export"],e)},exports.hasDirectives=p,exports.isDevelopment=Q,exports.isEnv=P,exports.isField=f,exports.isIdValue=function(e){return e&&"id"===e.type&&"boolean"==typeof e.generated},exports.isInlineFragment=l,exports.isJsonValue=function(e){return null!=e&&"object"==typeof e&&"json"===e.type},exports.isNumberValue=function(e){return["IntValue","FloatValue"].indexOf(e.kind)>-1},exports.isProduction=L,exports.isScalarValue=function(e){return["StringValue","BooleanValue","EnumValue"].indexOf(e.kind)>-1},exports.isTest=T,exports.maybeDeepFreeze=function(e){if(Q()||T()){var n="function"==typeof Symbol&&"string"==typeof Symbol("");if(!n)return function e(n){Object.freeze(n);Object.getOwnPropertyNames(n).forEach(function(t){null===n[t]||"object"!=typeof n[t]&&"function"!=typeof n[t]||Object.isFrozen(n[t])||e(n[t])});return n}(e)}return e},exports.mergeDeep=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return z(e)},exports.mergeDeepArray=z,exports.removeArgumentsFromDocument=N,exports.removeClientSetsFromDocument=function(e){y(e);var t=V([{test:function(e){return"client"===e.name.value},remove:!0}],e);t&&(t=(0,n.visit)(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet){var n=e.selectionSet.selections.every(function(e){return f(e)&&"__typename"===e.name.value});if(n)return null}}}}));return t},exports.removeConnectionDirectiveFromDocument=function(e){return V([j],y(e))},exports.removeDirectivesFromDocument=V,exports.removeFragmentSpreadFromDocument=q,exports.resultKeyNameFromField=function(e){return e.alias?e.alias.value:e.name.value},exports.shouldInclude=function(e,n){void 0===n&&(n={});return g(e.directives).every(function(e){var r=e.directive,i=e.ifArgument,o=!1;return"Variable"===i.value.kind?(o=n[i.value.name.value],(0,t.invariant)(void 0!==o,13)):o=i.value.value,"skip"===r.name.value?!o:o})},exports.storeKeyNameFromField=function(e,n){var t=null;e.directives&&(t={},e.directives.forEach(function(e){t[e.name.value]={},e.arguments&&e.arguments.forEach(function(r){var i=r.name,o=r.value;return a(t[e.name.value],i,o,n)})}));var r=null;e.arguments&&e.arguments.length&&(r={},e.arguments.forEach(function(e){var t=e.name,i=e.value;return a(r,t,i,n)}));return c(e.name.value,r,t)},exports.stripSymbols=function(e){return JSON.parse(JSON.stringify(e))},exports.toIdValue=function(e,n){void 0===n&&(n=!1);return(0,r.__assign)({type:"id",generated:n},"string"==typeof e?{id:e,typename:void 0}:e)},exports.tryFunctionOrLogError=function(e){try{return e()}catch(e){console.error&&console.error(e)}},exports.valueFromNode=function e(n,t){void 0===t&&(t=v);switch(n.kind){case"Variable":return t(n);case"NullValue":return null;case"IntValue":return parseInt(n.value,10);case"FloatValue":return parseFloat(n.value);case"ListValue":return n.values.map(function(n){return e(n,t)});case"ObjectValue":for(var r={},i=0,o=n.fields;i<o.length;i++){var a=o[i];r[a.name.value]=e(a.value,t)}return r;default:return n.value}},exports.valueToObjectRepresentation=a,exports.variablesInOperation=function(e){var n=new Set;if(e.variableDefinitions)for(var t=0,r=e.variableDefinitions;t<r.length;t++){var i=r[t];n.add(i.variable.name.value)}return n},exports.warnOnceInDevelopment=function(e,n){void 0===n&&(n="warn");L()||R[e]||(T()||(R[e]=!0),"error"===n?console.error(e):console.warn(e))},exports.canUseWeakMap=exports.isEqual=void 0;var e,n=require("graphql/language/visitor"),t=require("ts-invariant"),r=require("tslib"),i=(e=require("fast-json-stable-stringify"))&&e.__esModule?e:{default:e},o=require("@wry/equality");function a(e,n,r,i){if(function(e){return"IntValue"===e.kind}(r)||function(e){return"FloatValue"===e.kind}(r))e[n.value]=Number(r.value);else if(function(e){return"BooleanValue"===e.kind}(r)||function(e){return"StringValue"===e.kind}(r))e[n.value]=r.value;else if(function(e){return"ObjectValue"===e.kind}(r)){var o={};r.fields.map(function(e){return a(o,e.name,e.value,i)}),e[n.value]=o}else if(function(e){return"Variable"===e.kind}(r)){var u=(i||{})[r.name.value];e[n.value]=u}else if(function(e){return"ListValue"===e.kind}(r))e[n.value]=r.values.map(function(e){var t={};return a(t,n,e,i),t[n.value]});else if(function(e){return"EnumValue"===e.kind}(r))e[n.value]=r.value;else{if(!function(e){return"NullValue"===e.kind}(r))throw new t.InvariantError(17);e[n.value]=null}}exports.isEqual=o.equal;var u=["connection","include","skip","client","rest","export"];function c(e,n,t){if(t&&t.connection&&t.connection.key){if(t.connection.filter&&t.connection.filter.length>0){var r=t.connection.filter?t.connection.filter:[];r.sort();var o=n,a={};return r.forEach(function(e){a[e]=o[e]}),t.connection.key+"("+JSON.stringify(a)+")"}return t.connection.key}var c=e;if(n){var s=(0,i.default)(n);c+="("+s+")"}return t&&Object.keys(t).forEach(function(e){-1===u.indexOf(e)&&(t[e]&&Object.keys(t[e]).length?c+="@"+e+"("+JSON.stringify(t[e])+")":c+="@"+e)}),c}function s(e,n){if(e.arguments&&e.arguments.length){var t={};return e.arguments.forEach(function(e){var r=e.name,i=e.value;return a(t,r,i,n)}),t}return null}function f(e){return"Field"===e.kind}function l(e){return"InlineFragment"===e.kind}function v(e){throw new t.InvariantError(18)}function m(e){var t=[];return(0,n.visit)(e,{Directive:function(e){t.push(e.name.value)}}),t}function p(e,n){return m(n).some(function(n){return e.indexOf(n)>-1})}function d(e){var n=e.name.value;return"skip"===n||"include"===n}function g(e){return e?e.filter(d).map(function(e){var n=e.arguments;e.name.value;(0,t.invariant)(n&&1===n.length,14);var r=n[0];(0,t.invariant)(r.name&&"if"===r.name.value,15);var i=r.value;return(0,t.invariant)(i&&("Variable"===i.kind||"BooleanValue"===i.kind),16),{directive:e,ifArgument:r}}):[]}function x(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return n.forEach(function(n){null!=n&&Object.keys(n).forEach(function(t){e[t]=n[t]})}),e}function y(e){(0,t.invariant)(e&&"Document"===e.kind,2);var n=e.definitions.filter(function(e){return"FragmentDefinition"!==e.kind}).map(function(e){if("OperationDefinition"!==e.kind)throw new t.InvariantError(3);return e});return(0,t.invariant)(n.length<=1,4),e}function h(e){return y(e),e.definitions.filter(function(e){return"OperationDefinition"===e.kind})[0]}function b(e){return e.definitions.filter(function(e){return"FragmentDefinition"===e.kind})}function D(e){(0,t.invariant)("Document"===e.kind,7),(0,t.invariant)(e.definitions.length<=1,8);var n=e.definitions[0];return(0,t.invariant)("FragmentDefinition"===n.kind,9),n}function k(e){var n;y(e);for(var r=0,i=e.definitions;r<i.length;r++){var o=i[r];if("OperationDefinition"===o.kind){var a=o.operation;if("query"===a||"mutation"===a||"subscription"===a)return o}"FragmentDefinition"!==o.kind||n||(n=o)}if(n)return n;throw new t.InvariantError(10)}function O(e){void 0===e&&(e=[]);var n={};return e.forEach(function(e){n[e.name.value]=e}),n}function F(e,n,t){var r=0;return e.forEach(function(t,i){n.call(this,t,i,e)&&(e[r++]=t)},t),e.length=r,e}var _={kind:"Field",name:{kind:"Name",value:"__typename"}};function E(e){return function e(n,t){return n.selectionSet.selections.every(function(n){return"FragmentSpread"===n.kind&&e(t[n.name.value],t)})}(h(e)||D(e),O(b(e)))?null:e}function S(e){return function(n){return e.some(function(e){return e.name&&e.name===n.name.value||e.test&&e.test(n)})}}function V(e,t){var r=Object.create(null),i=[],o=Object.create(null),a=[],u=E((0,n.visit)(t,{Variable:{enter:function(e,n,t){"VariableDefinition"!==t.kind&&(r[e.name.value]=!0)}},Field:{enter:function(n){if(e&&n.directives&&(e.some(function(e){return e.remove})&&n.directives&&n.directives.some(S(e))))return n.arguments&&n.arguments.forEach(function(e){"Variable"===e.value.kind&&i.push({name:e.value.name.value})}),n.selectionSet&&function e(n){var t=[];n.selections.forEach(function(n){(f(n)||l(n))&&n.selectionSet?e(n.selectionSet).forEach(function(e){return t.push(e)}):"FragmentSpread"===n.kind&&t.push(n)});return t}(n.selectionSet).forEach(function(e){a.push({name:e.name.value})}),null}},FragmentSpread:{enter:function(e){o[e.name.value]=!0}},Directive:{enter:function(n){if(S(e)(n))return null}}}));return u&&F(i,function(e){return!r[e.name]}).length&&(u=N(i,u)),u&&F(a,function(e){return!o[e.name]}).length&&(u=q(a,u)),u}var j={test:function(e){var n="connection"===e.name.value;return n&&(!e.arguments||e.arguments.some(function(e){return"key"===e.name.value})),n}};function w(e,n,t){return void 0===t&&(t=!0),n&&n.selections&&n.selections.some(function(n){return I(e,n,t)})}function I(e,n,t){return void 0===t&&(t=!0),!f(n)||!!n.directives&&(n.directives.some(S(e))||t&&w(e,n.selectionSet,t))}function N(e,t){var i=function(e){return function(n){return e.some(function(e){return n.value&&"Variable"===n.value.kind&&n.value.name&&(e.name===n.value.name.value||e.test&&e.test(n))})}}(e);return E((0,n.visit)(t,{OperationDefinition:{enter:function(n){return(0,r.__assign)((0,r.__assign)({},n),{variableDefinitions:n.variableDefinitions.filter(function(n){return!e.some(function(e){return e.name===n.variable.name.value})})})}},Field:{enter:function(n){if(e.some(function(e){return e.remove})){var t=0;if(n.arguments.forEach(function(e){i(e)&&(t+=1)}),1===t)return null}}},Argument:{enter:function(e){if(i(e))return null}}}))}function q(e,t){function r(n){if(e.some(function(e){return e.name===n.name.value}))return null}return E((0,n.visit)(t,{FragmentSpread:{enter:r},FragmentDefinition:{enter:r}}))}var A="function"==typeof WeakMap&&!("object"==typeof navigator&&"ReactNative"===navigator.product);exports.canUseWeakMap=A;var M=Object.prototype.toString;function J(){return"undefined"!=typeof process?"production":"development"}function P(e){return J()===e}function L(){return!0===P("production")}function Q(){return!0===P("development")}function T(){return!0===P("test")}var W=Object.prototype.hasOwnProperty;function z(e){var n=e[0]||{},t=e.length;if(t>1){var r=[];n=K(n,r);for(var i=1;i<t;++i)n=C(n,e[i],r)}return n}function B(e){return null!==e&&"object"==typeof e}function C(e,n,t){return B(n)&&B(e)?(Object.isExtensible&&!Object.isExtensible(e)&&(e=K(e,t)),Object.keys(n).forEach(function(r){var i=n[r];if(W.call(e,r)){var o=e[r];i!==o&&(e[r]=C(K(o,t),i,t))}else e[r]=i}),e):n}function K(e,n){return null!==e&&"object"==typeof e&&n.indexOf(e)<0&&(e=Array.isArray(e)?e.slice(0):(0,r.__assign)({__proto__:Object.getPrototypeOf(e)},e),n.push(e)),e}var R=Object.create({}); |
@@ -231,3 +231,3 @@ import { visit } from 'graphql/language/visitor'; | ||
evaledValue = variables[ifArgument.value.name.value]; | ||
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 1) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
process.env.NODE_ENV === "production" ? invariant(evaledValue !== void 0, 13) : invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
} | ||
@@ -265,8 +265,8 @@ else { | ||
var directiveName = directive.name.value; | ||
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 2) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? invariant(directiveArguments && directiveArguments.length === 1, 14) : invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
var ifArgument = directiveArguments[0]; | ||
process.env.NODE_ENV === "production" ? invariant(ifArgument.name && ifArgument.name.value === 'if', 3) : invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? invariant(ifArgument.name && ifArgument.name.value === 'if', 15) : invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
var ifValue = ifArgument.value; | ||
process.env.NODE_ENV === "production" ? invariant(ifValue && | ||
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 4) : invariant(ifValue && | ||
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 16) : invariant(ifValue && | ||
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value."); | ||
@@ -282,3 +282,3 @@ return { directive: directive, ifArgument: ifArgument }; | ||
if (definition.kind === 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(5) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(11) : new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + | ||
'No operations are allowed when using a fragment as a query. Only fragments are allowed.'); | ||
@@ -291,3 +291,3 @@ } | ||
if (typeof actualFragmentName === 'undefined') { | ||
process.env.NODE_ENV === "production" ? invariant(fragments.length === 1, 6) : invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
process.env.NODE_ENV === "production" ? invariant(fragments.length === 1, 12) : invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
actualFragmentName = fragments[0].name.value; | ||
@@ -338,7 +338,7 @@ } | ||
})[0]; | ||
process.env.NODE_ENV === "production" ? invariant(mutationDef, 7) : invariant(mutationDef, 'Must contain a mutation definition.'); | ||
process.env.NODE_ENV === "production" ? invariant(mutationDef, 1) : invariant(mutationDef, 'Must contain a mutation definition.'); | ||
return mutationDef; | ||
} | ||
function checkDocument(doc) { | ||
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 8) : invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? invariant(doc && doc.kind === 'Document', 2) : invariant(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
var operations = doc.definitions | ||
@@ -348,7 +348,7 @@ .filter(function (d) { return d.kind !== 'FragmentDefinition'; }) | ||
if (definition.kind !== 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(9) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(3) : new InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
} | ||
return definition; | ||
}); | ||
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 10) : invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
process.env.NODE_ENV === "production" ? invariant(operations.length <= 1, 4) : invariant(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
return doc; | ||
@@ -362,3 +362,3 @@ } | ||
var def = getOperationDefinition(document); | ||
process.env.NODE_ENV === "production" ? invariant(def, 11) : invariant(def, "GraphQL document is missing an operation"); | ||
process.env.NODE_ENV === "production" ? invariant(def, 5) : invariant(def, "GraphQL document is missing an operation"); | ||
return def; | ||
@@ -378,10 +378,10 @@ } | ||
var queryDef = getOperationDefinition(doc); | ||
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 12) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
process.env.NODE_ENV === "production" ? invariant(queryDef && queryDef.operation === 'query', 6) : invariant(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
return queryDef; | ||
} | ||
function getFragmentDefinition(doc) { | ||
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 13) : invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? invariant(doc.definitions.length <= 1, 14) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
process.env.NODE_ENV === "production" ? invariant(doc.kind === 'Document', 7) : invariant(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? invariant(doc.definitions.length <= 1, 8) : invariant(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
var fragmentDef = doc.definitions[0]; | ||
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 15) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
process.env.NODE_ENV === "production" ? invariant(fragmentDef.kind === 'FragmentDefinition', 9) : invariant(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
return fragmentDef; | ||
@@ -409,3 +409,3 @@ } | ||
} | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(16) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
throw process.env.NODE_ENV === "production" ? new InvariantError(10) : new InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
} | ||
@@ -412,0 +412,0 @@ function createFragmentMap(fragments) { |
@@ -337,3 +337,3 @@ (function (global, factory) { | ||
evaledValue = variables[ifArgument.value.name.value]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(evaledValue !== void 0, 1) : (0, _tsInvariant.invariant)(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(evaledValue !== void 0, 13) : (0, _tsInvariant.invariant)(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive."); | ||
} else { | ||
@@ -376,7 +376,7 @@ evaledValue = ifArgument.value.value; | ||
var directiveName = directive.name.value; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, 2) : (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, 14) : (0, _tsInvariant.invariant)(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive."); | ||
var ifArgument = directiveArguments[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', 3) : (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', 15) : (0, _tsInvariant.invariant)(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive."); | ||
var ifValue = ifArgument.value; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 4) : (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 16) : (0, _tsInvariant.invariant)(ifValue && (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value."); | ||
return { | ||
@@ -394,3 +394,3 @@ directive: directive, | ||
if (definition.kind === 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(5) : new _tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + 'No operations are allowed when using a fragment as a query. Only fragments are allowed.'); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(11) : new _tsInvariant.InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " + 'No operations are allowed when using a fragment as a query. Only fragments are allowed.'); | ||
} | ||
@@ -404,3 +404,3 @@ | ||
if (typeof actualFragmentName === 'undefined') { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragments.length === 1, 6) : (0, _tsInvariant.invariant)(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragments.length === 1, 12) : (0, _tsInvariant.invariant)(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment."); | ||
actualFragmentName = fragments[0].name.value; | ||
@@ -452,3 +452,3 @@ } | ||
})[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(mutationDef, 7) : (0, _tsInvariant.invariant)(mutationDef, 'Must contain a mutation definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(mutationDef, 1) : (0, _tsInvariant.invariant)(mutationDef, 'Must contain a mutation definition.'); | ||
return mutationDef; | ||
@@ -458,3 +458,3 @@ } | ||
function checkDocument(doc) { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', 8) : (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', 2) : (0, _tsInvariant.invariant)(doc && doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
var operations = doc.definitions.filter(function (d) { | ||
@@ -464,3 +464,3 @@ return d.kind !== 'FragmentDefinition'; | ||
if (definition.kind !== 'OperationDefinition') { | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(9) : new _tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(3) : new _tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"" + definition.kind + "\""); | ||
} | ||
@@ -470,3 +470,3 @@ | ||
}); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(operations.length <= 1, 10) : (0, _tsInvariant.invariant)(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(operations.length <= 1, 4) : (0, _tsInvariant.invariant)(operations.length <= 1, "Ambiguous GraphQL document: contains " + operations.length + " operations"); | ||
return doc; | ||
@@ -484,3 +484,3 @@ } | ||
var def = getOperationDefinition(document); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(def, 11) : (0, _tsInvariant.invariant)(def, "GraphQL document is missing an operation"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(def, 5) : (0, _tsInvariant.invariant)(def, "GraphQL document is missing an operation"); | ||
return def; | ||
@@ -505,3 +505,3 @@ } | ||
var queryDef = getOperationDefinition(doc); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 12) : (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 6) : (0, _tsInvariant.invariant)(queryDef && queryDef.operation === 'query', 'Must contain a query definition.'); | ||
return queryDef; | ||
@@ -511,6 +511,6 @@ } | ||
function getFragmentDefinition(doc) { | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.kind === 'Document', 13) : (0, _tsInvariant.invariant)(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 14) : (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.kind === 'Document', 7) : (0, _tsInvariant.invariant)(doc.kind === 'Document', "Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a \"gql\" tag? http://docs.apollostack.com/apollo-client/core.html#gql"); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 8) : (0, _tsInvariant.invariant)(doc.definitions.length <= 1, 'Fragment must have exactly one definition.'); | ||
var fragmentDef = doc.definitions[0]; | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 15) : (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
process.env.NODE_ENV === "production" ? (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 9) : (0, _tsInvariant.invariant)(fragmentDef.kind === 'FragmentDefinition', 'Must be a fragment definition.'); | ||
return fragmentDef; | ||
@@ -543,3 +543,3 @@ } | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(16) : new _tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
throw process.env.NODE_ENV === "production" ? new _tsInvariant.InvariantError(10) : new _tsInvariant.InvariantError('Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment.'); | ||
} | ||
@@ -546,0 +546,0 @@ |
{ | ||
"name": "apollo-utilities", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Utilities for working with GraphQL ASTs", | ||
@@ -33,3 +33,3 @@ "author": "James Baxley <james@meteor.com>", | ||
"postbuild": "npm run bundle", | ||
"bundle": "../../node_modules/rollup/bin/rollup -c rollup.config.js", | ||
"bundle": "npx rollup -c rollup.config.js", | ||
"watch": "../../node_modules/tsc-watch/index.js --onSuccess \"npm run postbuild\"", | ||
@@ -40,3 +40,3 @@ "clean": "rm -rf coverage/* lib/*", | ||
"peerDependencies": { | ||
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0" | ||
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" | ||
}, | ||
@@ -49,3 +49,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "68fa57751ce201ba6b72efdbf8fdda1729c991cc" | ||
"gitHead": "d22394c419ff7d678afb5e7d4cd1df16ed803ead" | ||
} |
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
567478
0