From db103311b65e223efd34d8ae27201d3721e0d6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=CC=88llar=20Esinurm?= Date: Wed, 26 Aug 2020 10:46:21 +0300 Subject: [PATCH 1/3] Make getInputTypeName action work --- src/actions/action.ts | 16 ++++++++++------ src/actions/destroy.ts | 3 ++- src/actions/fetch.ts | 4 +++- src/actions/mutate.ts | 5 +++-- src/actions/persist.ts | 5 +++-- src/actions/push.ts | 5 +++-- src/actions/query.ts | 5 +++-- src/graphql/query-builder.ts | 19 ++++++++++++++----- src/graphql/transformer.ts | 17 +++++++++++++---- 9 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/actions/action.ts b/src/actions/action.ts index 4c6d6bd3..2e4015d9 100644 --- a/src/actions/action.ts +++ b/src/actions/action.ts @@ -19,6 +19,7 @@ export default class Action { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ @@ -26,14 +27,15 @@ export default class Action { name: string, variables: Data | undefined, dispatch: DispatchFunction, - model: Model + model: Model, + action: string ): Promise { if (variables) { const context: Context = Context.getInstance(); const schema: Schema = await context.loadSchema(); const multiple: boolean = Schema.returnsConnection(schema.getMutation(name)!); - const query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + const query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); // Send GraphQL Mutation let newData = await context.apollo.request(model, query, variables, true); @@ -101,19 +103,21 @@ export default class Action { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args: Arguments, model: Model, data: Data): Arguments { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string): Arguments { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; } /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - protected static transformArgs(args: Arguments): Arguments { + protected static transformArgs(args: Arguments, action: string): Arguments { const context = Context.getInstance(); Object.keys(args).forEach((key: string) => { @@ -121,7 +125,7 @@ export default class Action { if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log( "A", key, diff --git a/src/actions/destroy.ts b/src/actions/destroy.ts index 9ee4166b..9b8cc9be 100644 --- a/src/actions/destroy.ts +++ b/src/actions/destroy.ts @@ -41,6 +41,7 @@ export default class Destroy extends Action { if (id) { const model = this.getModelFromState(state!); const mutationName = Context.getInstance().adapter.getNameForDestroy(model); + const action = 'destroy' const mockReturnValue = model.$mockHook("destroy", { id }); @@ -51,7 +52,7 @@ export default class Destroy extends Action { args = this.prepareArgs(args, id); - await Action.mutation(mutationName, args as Data, dispatch!, model); + await Action.mutation(mutationName, args as Data, dispatch!, model, action); return true; } else { /* istanbul ignore next */ diff --git a/src/actions/fetch.ts b/src/actions/fetch.ts index 311b4483..da56a504 100644 --- a/src/actions/fetch.ts +++ b/src/actions/fetch.ts @@ -39,6 +39,7 @@ export default class Fetch extends Action { ): Promise { const context = Context.getInstance(); const model = this.getModelFromState(state!); + const action = 'fetch' const mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} @@ -58,6 +59,7 @@ export default class Fetch extends Action { model, params.filter as Data, true, + action, Object.keys(params.filter) ); } @@ -67,7 +69,7 @@ export default class Fetch extends Action { // When the filter contains an id, we query in singular mode const multiple: boolean = !filter["id"]; const name: string = context.adapter.getNameForFetch(model, multiple); - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache as boolean); diff --git a/src/actions/mutate.ts b/src/actions/mutate.ts index f8f43290..a1f8f7a1 100644 --- a/src/actions/mutate.ts +++ b/src/actions/mutate.ts @@ -46,6 +46,7 @@ export default class Mutate extends Action { if (name) { const context: Context = Context.getInstance(); const model = this.getModelFromState(state!); + const action = 'mutate' const mockReturnValue = model.$mockHook("mutate", { name, @@ -61,10 +62,10 @@ export default class Mutate extends Action { // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return Action.mutation(name, args as Data, dispatch!, model); + return Action.mutation(name, args as Data, dispatch!, model, action); } else { /* istanbul ignore next */ throw new Error("The mutate action requires the mutation name ('mutation') to be set"); diff --git a/src/actions/persist.ts b/src/actions/persist.ts index 26e8c597..58039095 100644 --- a/src/actions/persist.ts +++ b/src/actions/persist.ts @@ -37,6 +37,7 @@ export default class Persist extends Action { const model = this.getModelFromState(state!); const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id)!; + const action = 'persist' const mockReturnValue = model.$mockHook("persist", { id: toNumber(id), @@ -52,10 +53,10 @@ export default class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); + this.addRecordToArgs(args, model, oldRecord, action); // Send mutation - const newRecord = await Action.mutation(mutationName, args as Data, dispatch!, model); + const newRecord = await Action.mutation(mutationName, args as Data, dispatch!, model, action); // Delete the old record if necessary await this.deleteObsoleteRecord(model, newRecord, oldRecord); diff --git a/src/actions/push.ts b/src/actions/push.ts index 1e3fa205..206c98bf 100644 --- a/src/actions/push.ts +++ b/src/actions/push.ts @@ -35,6 +35,7 @@ export default class Push extends Action { if (data) { const model = this.getModelFromState(state!); const mutationName = Context.getInstance().adapter.getNameForPush(model); + const action = 'push' const mockReturnValue = model.$mockHook("push", { data, @@ -48,10 +49,10 @@ export default class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return Action.mutation(mutationName, args as Data, dispatch!, model); + return Action.mutation(mutationName, args as Data, dispatch!, model, action); } else { /* istanbul ignore next */ throw new Error("The persist action requires the 'data' to be set"); diff --git a/src/actions/query.ts b/src/actions/query.ts index 003ca4ea..de8d9373 100644 --- a/src/actions/query.ts +++ b/src/actions/query.ts @@ -50,6 +50,7 @@ export default class Query extends Action { if (name) { const context: Context = Context.getInstance(); const model = this.getModelFromState(state!); + const action = 'query' const mockReturnValue = model.$mockHook("query", { name, @@ -63,13 +64,13 @@ export default class Query extends Action { const schema: Schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter as Data, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter as Data, true, action) : {}; // Multiple? const multiple: boolean = Schema.returnsConnection(schema.getQuery(name)!); // Build query - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); // Send the request to the GraphQL API const data = await context.apollo.request( diff --git a/src/graphql/query-builder.ts b/src/graphql/query-builder.ts index 6eb2b431..70e381fb 100644 --- a/src/graphql/query-builder.ts +++ b/src/graphql/query-builder.ts @@ -15,6 +15,7 @@ export default class QueryBuilder { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -29,6 +30,7 @@ export default class QueryBuilder { */ public static buildField( model: Model | string, + action: string, multiple: boolean = true, args?: Arguments, path: Array = [], @@ -42,12 +44,12 @@ export default class QueryBuilder { name = name ? name : model.pluralName; const field = context.schema!.getMutation(name, true) || context.schema!.getQuery(name, true); - let params: string = this.buildArguments(model, args, false, filter, allowIdFields, field); + let params: string = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; const fields = ` ${model.getQueryFields().join(" ")} - ${this.buildRelationsQuery(model, path)} + ${this.buildRelationsQuery(model, path, action)} `; if (multiple) { @@ -100,6 +102,7 @@ export default class QueryBuilder { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) @@ -109,6 +112,7 @@ export default class QueryBuilder { public static buildQuery( type: string, model: Model | string, + action: string, name?: string, args?: Arguments, multiple?: boolean, @@ -135,13 +139,14 @@ export default class QueryBuilder { const query: string = `${type} ${upcaseFirstLetter(name)}${this.buildArguments( model, + action, args, true, filter, true, field )} {\n` + - ` ${this.buildField(model, multiple, args, [], name, filter, true)}\n` + + ` ${this.buildField(model, action, multiple, args, [], name, filter, true)}\n` + `}`; return gql(query); @@ -165,6 +170,7 @@ export default class QueryBuilder { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -174,6 +180,7 @@ export default class QueryBuilder { */ public static buildArguments( model: Model, + action: string, args?: Arguments, signature: boolean = false, filter: boolean = false, @@ -210,7 +217,7 @@ export default class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -358,9 +365,10 @@ export default class QueryBuilder { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model: null | Model, path: Array = []): string { + static buildRelationsQuery(model: null | Model, path: Array = [], action: string): string { if (model === null) return ""; const context = Context.getInstance(); @@ -390,6 +398,7 @@ export default class QueryBuilder { relationQueries.push( this.buildField( relatedModel, + action, Model.isConnection(field as Field), undefined, newPath, diff --git a/src/graphql/transformer.ts b/src/graphql/transformer.ts index ce2a7da6..20edf75b 100644 --- a/src/graphql/transformer.ts +++ b/src/graphql/transformer.ts @@ -22,6 +22,7 @@ export default class Transformer { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. @@ -32,6 +33,7 @@ export default class Transformer { model: Model, data: Data, read: boolean, + action: string, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean @@ -64,6 +66,7 @@ export default class Transformer { key, value, model, + action, whitelist ) ) { @@ -80,6 +83,7 @@ export default class Transformer { arrayModel || model, v, read, + action, undefined, outgoingRecords, true @@ -101,6 +105,7 @@ export default class Transformer { relatedModel, value, read, + action, undefined, outgoingRecords, true @@ -207,6 +212,7 @@ export default class Transformer { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ @@ -215,6 +221,7 @@ export default class Transformer { fieldName: string, value: any, model: Model, + action: string, whitelist?: Array ): boolean { // Always add fields on the whitelist. @@ -230,7 +237,7 @@ export default class Transformer { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) return false; + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -253,10 +260,12 @@ export default class Transformer { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - private static inputTypeContainsField(model: Model, fieldName: string): boolean { - const inputTypeName = `${model.singularName}Input`; - const inputType: GraphQLType | null = Context.getInstance().schema!.getType( + private static inputTypeContainsField(model: Model, fieldName: string, action: string): boolean { + const context = Context.getInstance(); + const inputTypeName = context.adapter.getInputTypeName(model, action); + const inputType: GraphQLType | null = context.schema!.getType( inputTypeName, false ); From 7f16ba85123c3b99e01abfc17a3ddb82188154d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=CC=88llar=20Esinurm?= Date: Wed, 26 Aug 2020 11:38:25 +0300 Subject: [PATCH 2/3] Build rc 42 --- dist/actions/action.d.ts | 9 ++- dist/graphql/query-builder.d.ts | 12 ++-- dist/graphql/transformer.d.ts | 7 +- dist/vuex-orm-graphql.cjs.js | 101 ++++++++++++++++----------- dist/vuex-orm-graphql.esm-bundler.js | 89 +++++++++++++---------- dist/vuex-orm-graphql.esm.js | 89 +++++++++++++---------- dist/vuex-orm-graphql.esm.prod.js | 89 +++++++++++++---------- dist/vuex-orm-graphql.global.js | 101 ++++++++++++++++----------- dist/vuex-orm-graphql.global.prod.js | 2 +- 9 files changed, 297 insertions(+), 202 deletions(-) diff --git a/dist/actions/action.d.ts b/dist/actions/action.d.ts index d9e64c22..1c68f600 100644 --- a/dist/actions/action.d.ts +++ b/dist/actions/action.d.ts @@ -12,10 +12,11 @@ export default class Action { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - protected static mutation(name: string, variables: Data | undefined, dispatch: DispatchFunction, model: Model): Promise; + protected static mutation(name: string, variables: Data | undefined, dispatch: DispatchFunction, model: Model, action: string): Promise; /** * Convenience method to get the model from the state. * @param {RootState} state Vuex state @@ -37,13 +38,15 @@ export default class Action { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args: Arguments, model: Model, data: Data): Arguments; + static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string): Arguments; /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - protected static transformArgs(args: Arguments): Arguments; + protected static transformArgs(args: Arguments, action: string): Arguments; } diff --git a/dist/graphql/query-builder.d.ts b/dist/graphql/query-builder.d.ts index 05b0d8c5..fbcb1140 100644 --- a/dist/graphql/query-builder.d.ts +++ b/dist/graphql/query-builder.d.ts @@ -8,6 +8,7 @@ export default class QueryBuilder { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -20,19 +21,20 @@ export default class QueryBuilder { * * @todo Do we need the allowIdFields param? */ - static buildField(model: Model | string, multiple?: boolean, args?: Arguments, path?: Array, name?: string, filter?: boolean, allowIdFields?: boolean): string; + static buildField(model: Model | string, action: string, multiple?: boolean, args?: Arguments, path?: Array, name?: string, filter?: boolean, allowIdFields?: boolean): string; /** * Generates a query. * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - static buildQuery(type: string, model: Model | string, name?: string, args?: Arguments, multiple?: boolean, filter?: boolean): import("graphql").DocumentNode; + static buildQuery(type: string, model: Model | string, action: string, name?: string, args?: Arguments, multiple?: boolean, filter?: boolean): import("graphql").DocumentNode; /** * Generates the arguments string for a graphql query based on a given map. * @@ -51,6 +53,7 @@ export default class QueryBuilder { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -58,7 +61,7 @@ export default class QueryBuilder { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - static buildArguments(model: Model, args?: Arguments, signature?: boolean, filter?: boolean, allowIdFields?: boolean, field?: GraphQLField | null): string; + static buildArguments(model: Model, action: string, args?: Arguments, signature?: boolean, filter?: boolean, allowIdFields?: boolean, field?: GraphQLField | null): string; /** * Determines the GraphQL primitive type of a field in the variables hash by the field type or (when * the field type is generic attribute) by the variable type. @@ -75,8 +78,9 @@ export default class QueryBuilder { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model: null | Model, path?: Array): string; + static buildRelationsQuery(model: null | Model, path: string[] | undefined, action: string): string; private static prepareArguments; } diff --git a/dist/graphql/transformer.d.ts b/dist/graphql/transformer.d.ts index 5340e7b6..7ea7eace 100644 --- a/dist/graphql/transformer.d.ts +++ b/dist/graphql/transformer.d.ts @@ -11,13 +11,14 @@ export default class Transformer { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model: Model, data: Data, read: boolean, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean): Data; + static transformOutgoingData(model: Model, data: Data, read: boolean, action: string, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean): Data; /** * Transforms a set of incoming data to the format vuex-orm requires. * @@ -34,14 +35,16 @@ export default class Transformer { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, whitelist?: Array): boolean; + static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, action: string, whitelist?: Array): boolean; /** * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ private static inputTypeContainsField; /** diff --git a/dist/vuex-orm-graphql.cjs.js b/dist/vuex-orm-graphql.cjs.js index e3458345..c48d2c8d 100644 --- a/dist/vuex-orm-graphql.cjs.js +++ b/dist/vuex-orm-graphql.cjs.js @@ -14120,13 +14120,14 @@ var Transformer = /** @class */ (function () { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - Transformer.transformOutgoingData = function (model, data, read, whitelist, outgoingRecords, recursiveCall) { + Transformer.transformOutgoingData = function (model, data, read, action, whitelist, outgoingRecords, recursiveCall) { var _this = this; var context = Context.getInstance(); var relations = model.getRelations(); @@ -14149,7 +14150,7 @@ var Transformer = /** @class */ (function () { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, whitelist)) { + _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { var relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14157,7 +14158,7 @@ var Transformer = /** @class */ (function () { if (arrayModel_1) { _this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(function (v) { - return _this.transformOutgoingData(arrayModel_1 || model, v, read, undefined, outgoingRecords, true); + return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, undefined, outgoingRecords, true); }); } else { @@ -14171,7 +14172,7 @@ var Transformer = /** @class */ (function () { } _this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, undefined, outgoingRecords, true); + returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14257,10 +14258,11 @@ var Transformer = /** @class */ (function () { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, whitelist) { + Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14274,7 +14276,7 @@ var Transformer = /** @class */ (function () { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14295,10 +14297,12 @@ var Transformer = /** @class */ (function () { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - Transformer.inputTypeContainsField = function (model, fieldName) { - var inputTypeName = model.singularName + "Input"; - var inputType = Context.getInstance().schema.getType(inputTypeName, false); + Transformer.inputTypeContainsField = function (model, fieldName, action) { + var context = Context.getInstance(); + var inputTypeName = context.adapter.getInputTypeName(model, action); + var inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error("Type " + inputType + " doesn't exist."); return inputType.inputFields.find(function (f) { return f.name === fieldName; }) !== undefined; @@ -15000,6 +15004,7 @@ var QueryBuilder = /** @class */ (function () { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -15012,7 +15017,7 @@ var QueryBuilder = /** @class */ (function () { * * @todo Do we need the allowIdFields param? */ - QueryBuilder.buildField = function (model, multiple, args, path, name, filter, allowIdFields) { + QueryBuilder.buildField = function (model, action, multiple, args, path, name, filter, allowIdFields) { if (multiple === void 0) { multiple = true; } if (path === void 0) { path = []; } if (filter === void 0) { filter = false; } @@ -15021,9 +15026,9 @@ var QueryBuilder = /** @class */ (function () { model = context.getModel(model); name = name ? name : model.pluralName; var field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); - var params = this.buildArguments(model, args, false, filter, allowIdFields, field); + var params = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; - var fields = "\n " + model.getQueryFields().join(" ") + "\n " + this.buildRelationsQuery(model, path) + "\n "; + var fields = "\n " + model.getQueryFields().join(" ") + "\n " + this.buildRelationsQuery(model, path, action) + "\n "; if (multiple) { var header = "" + name + params; if (context.connectionMode === exports.ConnectionMode.NODES) { @@ -15048,13 +15053,14 @@ var QueryBuilder = /** @class */ (function () { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - QueryBuilder.buildQuery = function (type, model, name, args, multiple, filter) { + QueryBuilder.buildQuery = function (type, model, action, name, args, multiple, filter) { var context = Context.getInstance(); // model model = context.getModel(model); @@ -15068,8 +15074,8 @@ var QueryBuilder = /** @class */ (function () { // field var field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); // build query - var query = type + " " + upcaseFirstLetter(name) + this.buildArguments(model, args, true, filter, true, field) + " {\n" + - (" " + this.buildField(model, multiple, args, [], name, filter, true) + "\n") + + var query = type + " " + upcaseFirstLetter(name) + this.buildArguments(model, action, args, true, filter, true, field) + " {\n" + + (" " + this.buildField(model, action, multiple, args, [], name, filter, true) + "\n") + "}"; return src(query); }; @@ -15091,6 +15097,7 @@ var QueryBuilder = /** @class */ (function () { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -15098,7 +15105,7 @@ var QueryBuilder = /** @class */ (function () { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - QueryBuilder.buildArguments = function (model, args, signature, filter, allowIdFields, field) { + QueryBuilder.buildArguments = function (model, action, args, signature, filter, allowIdFields, field) { var _this = this; if (signature === void 0) { signature = false; } if (filter === void 0) { filter = false; } @@ -15122,7 +15129,7 @@ var QueryBuilder = /** @class */ (function () { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { var arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15241,9 +15248,10 @@ var QueryBuilder = /** @class */ (function () { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - QueryBuilder.buildRelationsQuery = function (model, path) { + QueryBuilder.buildRelationsQuery = function (model, path, action) { var _this = this; if (path === void 0) { path = []; } if (model === null) @@ -15264,7 +15272,7 @@ var QueryBuilder = /** @class */ (function () { if (model.shouldEagerLoadRelation(name, field, relatedModel) && !ignore) { var newPath = path.slice(0); newPath.push(relatedModel.singularName); - relationQueries.push(_this.buildField(relatedModel, Model.isConnection(field), undefined, newPath, name, false)); + relationQueries.push(_this.buildField(relatedModel, action, Model.isConnection(field), undefined, newPath, name, false)); } }); return relationQueries.join("\n"); @@ -15353,10 +15361,11 @@ var Action = /** @class */ (function () { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - Action.mutation = function (name, variables, dispatch, model) { + Action.mutation = function (name, variables, dispatch, model, action) { return __awaiter(this, void 0, void 0, function () { var context, schema, multiple, query, newData, insertedData, records, newRecord; var _a; @@ -15369,7 +15378,7 @@ var Action = /** @class */ (function () { case 1: schema = _b.sent(); multiple = Schema.returnsConnection(schema.getMutation(name)); - query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); return [4 /*yield*/, context.apollo.request(model, query, variables, true)]; case 2: newData = _b.sent(); @@ -15423,24 +15432,26 @@ var Action = /** @class */ (function () { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.addRecordToArgs = function (args, model, data) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + Action.addRecordToArgs = function (args, model, data, action) { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; }; /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.transformArgs = function (args) { + Action.transformArgs = function (args, action) { var context = Context.getInstance(); Object.keys(args).forEach(function (key) { var value = args[key]; if (value instanceof context.components.Model) { var model = context.getModel(singularize(value.$self().entity)); - var transformedValue = Transformer.transformOutgoingData(model, value, false); + var transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15496,13 +15507,14 @@ var Destroy = /** @class */ (function (_super) { var state = _a.state, dispatch = _a.dispatch; var id = _b.id, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, mockReturnValue; + var model, mutationName, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!id) return [3 /*break*/, 4]; model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForDestroy(model); + action = 'destroy'; mockReturnValue = model.$mockHook("destroy", { id: id }); if (!mockReturnValue) return [3 /*break*/, 2]; return [4 /*yield*/, Store.insertData(mockReturnValue, dispatch)]; @@ -15511,7 +15523,7 @@ var Destroy = /** @class */ (function (_super) { return [2 /*return*/, true]; case 2: args = this.prepareArgs(args, id); - return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model)]; + return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 3: _c.sent(); return [2 /*return*/, true]; @@ -15562,12 +15574,13 @@ var Fetch = /** @class */ (function (_super) { Fetch.call = function (_a, params) { var state = _a.state, dispatch = _a.dispatch; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue, filter, bypassCache, multiple, name, query, data; + var context, model, action, mockReturnValue, filter, bypassCache, multiple, name, query, data; return __generator(this, function (_b) { switch (_b.label) { case 0: context = Context.getInstance(); model = this.getModelFromState(state); + action = 'fetch'; mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} }); @@ -15579,12 +15592,12 @@ var Fetch = /** @class */ (function (_super) { _b.sent(); filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); } bypassCache = params && params.bypassCache; multiple = !filter["id"]; name = context.adapter.getNameForFetch(model, multiple); - query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; case 2: data = _b.sent(); @@ -15644,13 +15657,14 @@ var Mutate = /** @class */ (function (_super) { var state = _a.state, dispatch = _a.dispatch; var args = _b.args, name = _b.name; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue; + var context, model, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!name) return [3 /*break*/, 2]; context = Context.getInstance(); model = this.getModelFromState(state); + action = 'mutate'; mockReturnValue = model.$mockHook("mutate", { name: name, args: args || {} @@ -15664,9 +15678,9 @@ var Mutate = /** @class */ (function (_super) { args = this.prepareArgs(args); // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return [2 /*return*/, Action.mutation(name, args, dispatch, model)]; + return [2 /*return*/, Action.mutation(name, args, dispatch, model, action)]; case 2: /* istanbul ignore next */ throw new Error("The mutate action requires the mutation name ('mutation') to be set"); @@ -15710,7 +15724,7 @@ var Persist = /** @class */ (function (_super) { var state = _a.state, dispatch = _a.dispatch; var id = _b.id, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, oldRecord, mockReturnValue, newRecord_1, newRecord; + var model, mutationName, oldRecord, action, mockReturnValue, newRecord_1, newRecord; return __generator(this, function (_c) { switch (_c.label) { case 0: @@ -15718,6 +15732,7 @@ var Persist = /** @class */ (function (_super) { model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForPersist(model); oldRecord = model.getRecordWithId(id); + action = 'persist'; mockReturnValue = model.$mockHook("persist", { id: toNumber(id), args: args || {} @@ -15737,8 +15752,8 @@ var Persist = /** @class */ (function (_super) { // Arguments _c.sent(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); - return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model)]; + this.addRecordToArgs(args, model, oldRecord, action); + return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 5: newRecord = _c.sent(); // Delete the old record if necessary @@ -15810,13 +15825,14 @@ var Push = /** @class */ (function (_super) { var state = _a.state, dispatch = _a.dispatch; var data = _b.data, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, mockReturnValue; + var model, mutationName, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!data) return [3 /*break*/, 2]; model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForPush(model); + action = 'push'; mockReturnValue = model.$mockHook("push", { data: data, args: args || {} @@ -15830,9 +15846,9 @@ var Push = /** @class */ (function (_super) { // Arguments _c.sent(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model)]; + return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 2: /* istanbul ignore next */ throw new Error("The persist action requires the 'data' to be set"); @@ -15893,13 +15909,14 @@ var Query = /** @class */ (function (_super) { var state = _a.state, dispatch = _a.dispatch; var name = _b.name, filter = _b.filter, bypassCache = _b.bypassCache; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue, schema, multiple, query, data; + var context, model, action, mockReturnValue, schema, multiple, query, data; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!name) return [3 /*break*/, 3]; context = Context.getInstance(); model = this.getModelFromState(state); + action = 'query'; mockReturnValue = model.$mockHook("query", { name: name, filter: filter || {} @@ -15911,9 +15928,9 @@ var Query = /** @class */ (function (_super) { case 1: schema = _c.sent(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; multiple = Schema.returnsConnection(schema.getQuery(name)); - query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; case 2: data = _c.sent(); diff --git a/dist/vuex-orm-graphql.esm-bundler.js b/dist/vuex-orm-graphql.esm-bundler.js index 402a5492..fdb45c5e 100644 --- a/dist/vuex-orm-graphql.esm-bundler.js +++ b/dist/vuex-orm-graphql.esm-bundler.js @@ -14098,13 +14098,14 @@ class Transformer { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14126,7 +14127,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14134,7 +14135,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); }); } else { @@ -14148,7 +14149,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14231,10 +14232,11 @@ class Transformer { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14248,7 +14250,7 @@ class Transformer { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14269,10 +14271,12 @@ class Transformer { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName) { - const inputTypeName = `${model.singularName}Input`; - const inputType = Context.getInstance().schema.getType(inputTypeName, false); + static inputTypeContainsField(model, fieldName, action) { + const context = Context.getInstance(); + const inputTypeName = context.adapter.getInputTypeName(model, action); + const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); return inputType.inputFields.find(f => f.name === fieldName) !== undefined; @@ -14997,6 +15001,7 @@ class QueryBuilder { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -15009,16 +15014,16 @@ class QueryBuilder { * * @todo Do we need the allowIdFields param? */ - static buildField(model, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { + static buildField(model, action, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { const context = Context.getInstance(); model = context.getModel(model); name = name ? name : model.pluralName; const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); - let params = this.buildArguments(model, args, false, filter, allowIdFields, field); + let params = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; const fields = ` ${model.getQueryFields().join(" ")} - ${this.buildRelationsQuery(model, path)} + ${this.buildRelationsQuery(model, path, action)} `; if (multiple) { const header = `${name}${params}`; @@ -15072,13 +15077,14 @@ class QueryBuilder { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - static buildQuery(type, model, name, args, multiple, filter) { + static buildQuery(type, model, action, name, args, multiple, filter) { const context = Context.getInstance(); // model model = context.getModel(model); @@ -15092,8 +15098,8 @@ class QueryBuilder { // field const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); // build query - const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, args, true, filter, true, field)} {\n` + - ` ${this.buildField(model, multiple, args, [], name, filter, true)}\n` + + const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, action, args, true, filter, true, field)} {\n` + + ` ${this.buildField(model, action, multiple, args, [], name, filter, true)}\n` + `}`; return src(query); } @@ -15115,6 +15121,7 @@ class QueryBuilder { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -15122,7 +15129,7 @@ class QueryBuilder { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - static buildArguments(model, args, signature = false, filter = false, allowIdFields = true, field = null) { + static buildArguments(model, action, args, signature = false, filter = false, allowIdFields = true, field = null) { const context = Context.getInstance(); if (args === undefined) return ""; @@ -15141,7 +15148,7 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15260,9 +15267,10 @@ class QueryBuilder { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model, path = []) { + static buildRelationsQuery(model, path = [], action) { if (model === null) return ""; const context = Context.getInstance(); @@ -15281,7 +15289,7 @@ class QueryBuilder { if (model.shouldEagerLoadRelation(name, field, relatedModel) && !ignore) { const newPath = path.slice(0); newPath.push(relatedModel.singularName); - relationQueries.push(this.buildField(relatedModel, Model.isConnection(field), undefined, newPath, name, false)); + relationQueries.push(this.buildField(relatedModel, action, Model.isConnection(field), undefined, newPath, name, false)); } }); return relationQueries.join("\n"); @@ -15344,15 +15352,16 @@ class Action { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - static async mutation(name, variables, dispatch, model) { + static async mutation(name, variables, dispatch, model, action) { if (variables) { const context = Context.getInstance(); const schema = await context.loadSchema(); const multiple = Schema.returnsConnection(schema.getMutation(name)); - const query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + const query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); // Send GraphQL Mutation let newData = await context.apollo.request(model, query, variables, true); // When this was not a destroy action, we get new data, which we should insert in the store @@ -15403,24 +15412,26 @@ class Action { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + static addRecordToArgs(args, model, data, action) { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; } /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static transformArgs(args) { + static transformArgs(args, action) { const context = Context.getInstance(); Object.keys(args).forEach((key) => { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15459,13 +15470,14 @@ class Destroy extends Action { if (id) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForDestroy(model); + const action = 'destroy'; const mockReturnValue = model.$mockHook("destroy", { id }); if (mockReturnValue) { await Store.insertData(mockReturnValue, dispatch); return true; } args = this.prepareArgs(args, id); - await Action.mutation(mutationName, args, dispatch, model); + await Action.mutation(mutationName, args, dispatch, model, action); return true; } else { @@ -15502,6 +15514,7 @@ class Fetch extends Action { static async call({ state, dispatch }, params) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'fetch'; const mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} }); @@ -15512,13 +15525,13 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode const multiple = !filter["id"]; const name = context.adapter.getNameForFetch(model, multiple); - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store @@ -15560,6 +15573,7 @@ class Mutate extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'mutate'; const mockReturnValue = model.$mockHook("mutate", { name, args: args || {} @@ -15571,9 +15585,9 @@ class Mutate extends Action { args = this.prepareArgs(args); // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return Action.mutation(name, args, dispatch, model); + return Action.mutation(name, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15608,6 +15622,7 @@ class Persist extends Action { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); + const action = 'persist'; const mockReturnValue = model.$mockHook("persist", { id: toNumber(id), args: args || {} @@ -15620,9 +15635,9 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); + this.addRecordToArgs(args, model, oldRecord, action); // Send mutation - const newRecord = await Action.mutation(mutationName, args, dispatch, model); + const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary await this.deleteObsoleteRecord(model, newRecord, oldRecord); return newRecord; @@ -15675,6 +15690,7 @@ class Push extends Action { if (data) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPush(model); + const action = 'push'; const mockReturnValue = model.$mockHook("push", { data, args: args || {} @@ -15685,9 +15701,9 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return Action.mutation(mutationName, args, dispatch, model); + return Action.mutation(mutationName, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15732,6 +15748,7 @@ class Query extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'query'; const mockReturnValue = model.$mockHook("query", { name, filter: filter || {} @@ -15741,11 +15758,11 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store diff --git a/dist/vuex-orm-graphql.esm.js b/dist/vuex-orm-graphql.esm.js index 402a5492..fdb45c5e 100644 --- a/dist/vuex-orm-graphql.esm.js +++ b/dist/vuex-orm-graphql.esm.js @@ -14098,13 +14098,14 @@ class Transformer { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14126,7 +14127,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14134,7 +14135,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); }); } else { @@ -14148,7 +14149,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14231,10 +14232,11 @@ class Transformer { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14248,7 +14250,7 @@ class Transformer { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14269,10 +14271,12 @@ class Transformer { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName) { - const inputTypeName = `${model.singularName}Input`; - const inputType = Context.getInstance().schema.getType(inputTypeName, false); + static inputTypeContainsField(model, fieldName, action) { + const context = Context.getInstance(); + const inputTypeName = context.adapter.getInputTypeName(model, action); + const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); return inputType.inputFields.find(f => f.name === fieldName) !== undefined; @@ -14997,6 +15001,7 @@ class QueryBuilder { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -15009,16 +15014,16 @@ class QueryBuilder { * * @todo Do we need the allowIdFields param? */ - static buildField(model, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { + static buildField(model, action, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { const context = Context.getInstance(); model = context.getModel(model); name = name ? name : model.pluralName; const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); - let params = this.buildArguments(model, args, false, filter, allowIdFields, field); + let params = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; const fields = ` ${model.getQueryFields().join(" ")} - ${this.buildRelationsQuery(model, path)} + ${this.buildRelationsQuery(model, path, action)} `; if (multiple) { const header = `${name}${params}`; @@ -15072,13 +15077,14 @@ class QueryBuilder { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - static buildQuery(type, model, name, args, multiple, filter) { + static buildQuery(type, model, action, name, args, multiple, filter) { const context = Context.getInstance(); // model model = context.getModel(model); @@ -15092,8 +15098,8 @@ class QueryBuilder { // field const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); // build query - const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, args, true, filter, true, field)} {\n` + - ` ${this.buildField(model, multiple, args, [], name, filter, true)}\n` + + const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, action, args, true, filter, true, field)} {\n` + + ` ${this.buildField(model, action, multiple, args, [], name, filter, true)}\n` + `}`; return src(query); } @@ -15115,6 +15121,7 @@ class QueryBuilder { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -15122,7 +15129,7 @@ class QueryBuilder { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - static buildArguments(model, args, signature = false, filter = false, allowIdFields = true, field = null) { + static buildArguments(model, action, args, signature = false, filter = false, allowIdFields = true, field = null) { const context = Context.getInstance(); if (args === undefined) return ""; @@ -15141,7 +15148,7 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15260,9 +15267,10 @@ class QueryBuilder { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model, path = []) { + static buildRelationsQuery(model, path = [], action) { if (model === null) return ""; const context = Context.getInstance(); @@ -15281,7 +15289,7 @@ class QueryBuilder { if (model.shouldEagerLoadRelation(name, field, relatedModel) && !ignore) { const newPath = path.slice(0); newPath.push(relatedModel.singularName); - relationQueries.push(this.buildField(relatedModel, Model.isConnection(field), undefined, newPath, name, false)); + relationQueries.push(this.buildField(relatedModel, action, Model.isConnection(field), undefined, newPath, name, false)); } }); return relationQueries.join("\n"); @@ -15344,15 +15352,16 @@ class Action { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - static async mutation(name, variables, dispatch, model) { + static async mutation(name, variables, dispatch, model, action) { if (variables) { const context = Context.getInstance(); const schema = await context.loadSchema(); const multiple = Schema.returnsConnection(schema.getMutation(name)); - const query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + const query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); // Send GraphQL Mutation let newData = await context.apollo.request(model, query, variables, true); // When this was not a destroy action, we get new data, which we should insert in the store @@ -15403,24 +15412,26 @@ class Action { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + static addRecordToArgs(args, model, data, action) { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; } /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static transformArgs(args) { + static transformArgs(args, action) { const context = Context.getInstance(); Object.keys(args).forEach((key) => { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15459,13 +15470,14 @@ class Destroy extends Action { if (id) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForDestroy(model); + const action = 'destroy'; const mockReturnValue = model.$mockHook("destroy", { id }); if (mockReturnValue) { await Store.insertData(mockReturnValue, dispatch); return true; } args = this.prepareArgs(args, id); - await Action.mutation(mutationName, args, dispatch, model); + await Action.mutation(mutationName, args, dispatch, model, action); return true; } else { @@ -15502,6 +15514,7 @@ class Fetch extends Action { static async call({ state, dispatch }, params) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'fetch'; const mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} }); @@ -15512,13 +15525,13 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode const multiple = !filter["id"]; const name = context.adapter.getNameForFetch(model, multiple); - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store @@ -15560,6 +15573,7 @@ class Mutate extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'mutate'; const mockReturnValue = model.$mockHook("mutate", { name, args: args || {} @@ -15571,9 +15585,9 @@ class Mutate extends Action { args = this.prepareArgs(args); // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return Action.mutation(name, args, dispatch, model); + return Action.mutation(name, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15608,6 +15622,7 @@ class Persist extends Action { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); + const action = 'persist'; const mockReturnValue = model.$mockHook("persist", { id: toNumber(id), args: args || {} @@ -15620,9 +15635,9 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); + this.addRecordToArgs(args, model, oldRecord, action); // Send mutation - const newRecord = await Action.mutation(mutationName, args, dispatch, model); + const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary await this.deleteObsoleteRecord(model, newRecord, oldRecord); return newRecord; @@ -15675,6 +15690,7 @@ class Push extends Action { if (data) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPush(model); + const action = 'push'; const mockReturnValue = model.$mockHook("push", { data, args: args || {} @@ -15685,9 +15701,9 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return Action.mutation(mutationName, args, dispatch, model); + return Action.mutation(mutationName, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15732,6 +15748,7 @@ class Query extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'query'; const mockReturnValue = model.$mockHook("query", { name, filter: filter || {} @@ -15741,11 +15758,11 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store diff --git a/dist/vuex-orm-graphql.esm.prod.js b/dist/vuex-orm-graphql.esm.prod.js index 402a5492..fdb45c5e 100644 --- a/dist/vuex-orm-graphql.esm.prod.js +++ b/dist/vuex-orm-graphql.esm.prod.js @@ -14098,13 +14098,14 @@ class Transformer { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14126,7 +14127,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14134,7 +14135,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); }); } else { @@ -14148,7 +14149,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14231,10 +14232,11 @@ class Transformer { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14248,7 +14250,7 @@ class Transformer { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14269,10 +14271,12 @@ class Transformer { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName) { - const inputTypeName = `${model.singularName}Input`; - const inputType = Context.getInstance().schema.getType(inputTypeName, false); + static inputTypeContainsField(model, fieldName, action) { + const context = Context.getInstance(); + const inputTypeName = context.adapter.getInputTypeName(model, action); + const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); return inputType.inputFields.find(f => f.name === fieldName) !== undefined; @@ -14997,6 +15001,7 @@ class QueryBuilder { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -15009,16 +15014,16 @@ class QueryBuilder { * * @todo Do we need the allowIdFields param? */ - static buildField(model, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { + static buildField(model, action, multiple = true, args, path = [], name, filter = false, allowIdFields = false) { const context = Context.getInstance(); model = context.getModel(model); name = name ? name : model.pluralName; const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); - let params = this.buildArguments(model, args, false, filter, allowIdFields, field); + let params = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; const fields = ` ${model.getQueryFields().join(" ")} - ${this.buildRelationsQuery(model, path)} + ${this.buildRelationsQuery(model, path, action)} `; if (multiple) { const header = `${name}${params}`; @@ -15072,13 +15077,14 @@ class QueryBuilder { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - static buildQuery(type, model, name, args, multiple, filter) { + static buildQuery(type, model, action, name, args, multiple, filter) { const context = Context.getInstance(); // model model = context.getModel(model); @@ -15092,8 +15098,8 @@ class QueryBuilder { // field const field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); // build query - const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, args, true, filter, true, field)} {\n` + - ` ${this.buildField(model, multiple, args, [], name, filter, true)}\n` + + const query = `${type} ${upcaseFirstLetter(name)}${this.buildArguments(model, action, args, true, filter, true, field)} {\n` + + ` ${this.buildField(model, action, multiple, args, [], name, filter, true)}\n` + `}`; return src(query); } @@ -15115,6 +15121,7 @@ class QueryBuilder { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -15122,7 +15129,7 @@ class QueryBuilder { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - static buildArguments(model, args, signature = false, filter = false, allowIdFields = true, field = null) { + static buildArguments(model, action, args, signature = false, filter = false, allowIdFields = true, field = null) { const context = Context.getInstance(); if (args === undefined) return ""; @@ -15141,7 +15148,7 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15260,9 +15267,10 @@ class QueryBuilder { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model, path = []) { + static buildRelationsQuery(model, path = [], action) { if (model === null) return ""; const context = Context.getInstance(); @@ -15281,7 +15289,7 @@ class QueryBuilder { if (model.shouldEagerLoadRelation(name, field, relatedModel) && !ignore) { const newPath = path.slice(0); newPath.push(relatedModel.singularName); - relationQueries.push(this.buildField(relatedModel, Model.isConnection(field), undefined, newPath, name, false)); + relationQueries.push(this.buildField(relatedModel, action, Model.isConnection(field), undefined, newPath, name, false)); } }); return relationQueries.join("\n"); @@ -15344,15 +15352,16 @@ class Action { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - static async mutation(name, variables, dispatch, model) { + static async mutation(name, variables, dispatch, model, action) { if (variables) { const context = Context.getInstance(); const schema = await context.loadSchema(); const multiple = Schema.returnsConnection(schema.getMutation(name)); - const query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + const query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); // Send GraphQL Mutation let newData = await context.apollo.request(model, query, variables, true); // When this was not a destroy action, we get new data, which we should insert in the store @@ -15403,24 +15412,26 @@ class Action { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + static addRecordToArgs(args, model, data, action) { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; } /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static transformArgs(args) { + static transformArgs(args, action) { const context = Context.getInstance(); Object.keys(args).forEach((key) => { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15459,13 +15470,14 @@ class Destroy extends Action { if (id) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForDestroy(model); + const action = 'destroy'; const mockReturnValue = model.$mockHook("destroy", { id }); if (mockReturnValue) { await Store.insertData(mockReturnValue, dispatch); return true; } args = this.prepareArgs(args, id); - await Action.mutation(mutationName, args, dispatch, model); + await Action.mutation(mutationName, args, dispatch, model, action); return true; } else { @@ -15502,6 +15514,7 @@ class Fetch extends Action { static async call({ state, dispatch }, params) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'fetch'; const mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} }); @@ -15512,13 +15525,13 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode const multiple = !filter["id"]; const name = context.adapter.getNameForFetch(model, multiple); - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store @@ -15560,6 +15573,7 @@ class Mutate extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'mutate'; const mockReturnValue = model.$mockHook("mutate", { name, args: args || {} @@ -15571,9 +15585,9 @@ class Mutate extends Action { args = this.prepareArgs(args); // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return Action.mutation(name, args, dispatch, model); + return Action.mutation(name, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15608,6 +15622,7 @@ class Persist extends Action { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id); + const action = 'persist'; const mockReturnValue = model.$mockHook("persist", { id: toNumber(id), args: args || {} @@ -15620,9 +15635,9 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); + this.addRecordToArgs(args, model, oldRecord, action); // Send mutation - const newRecord = await Action.mutation(mutationName, args, dispatch, model); + const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary await this.deleteObsoleteRecord(model, newRecord, oldRecord); return newRecord; @@ -15675,6 +15690,7 @@ class Push extends Action { if (data) { const model = this.getModelFromState(state); const mutationName = Context.getInstance().adapter.getNameForPush(model); + const action = 'push'; const mockReturnValue = model.$mockHook("push", { data, args: args || {} @@ -15685,9 +15701,9 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return Action.mutation(mutationName, args, dispatch, model); + return Action.mutation(mutationName, args, dispatch, model, action); } else { /* istanbul ignore next */ @@ -15732,6 +15748,7 @@ class Query extends Action { if (name) { const context = Context.getInstance(); const model = this.getModelFromState(state); + const action = 'query'; const mockReturnValue = model.$mockHook("query", { name, filter: filter || {} @@ -15741,11 +15758,11 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query - const query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + const query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); // Send the request to the GraphQL API const data = await context.apollo.request(model, query, filter, false, bypassCache); // Insert incoming data into the store diff --git a/dist/vuex-orm-graphql.global.js b/dist/vuex-orm-graphql.global.js index eed75cda..1f623d32 100644 --- a/dist/vuex-orm-graphql.global.js +++ b/dist/vuex-orm-graphql.global.js @@ -14119,13 +14119,14 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {Model} model Base model of the mutation/query * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - Transformer.transformOutgoingData = function (model, data, read, whitelist, outgoingRecords, recursiveCall) { + Transformer.transformOutgoingData = function (model, data, read, action, whitelist, outgoingRecords, recursiveCall) { var _this = this; var context = Context.getInstance(); var relations = model.getRelations(); @@ -14148,7 +14149,7 @@ var VuexORMGraphQLPlugin = (function (exports) { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, whitelist)) { + _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { var relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14156,7 +14157,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (arrayModel_1) { _this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(function (v) { - return _this.transformOutgoingData(arrayModel_1 || model, v, read, undefined, outgoingRecords, true); + return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, undefined, outgoingRecords, true); }); } else { @@ -14170,7 +14171,7 @@ var VuexORMGraphQLPlugin = (function (exports) { } _this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, undefined, outgoingRecords, true); + returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14256,10 +14257,11 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {string} fieldName Name of the field to check. * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, whitelist) { + Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14273,7 +14275,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (value === null || value === undefined) return false; // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName)) + if (!this.inputTypeContainsField(model, fieldName, action)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14294,10 +14296,12 @@ var VuexORMGraphQLPlugin = (function (exports) { * Tells whether a field is in the input type. * @param {Model} model * @param {string} fieldName + * @param {string} action Name of the current action like 'persist' or 'push' */ - Transformer.inputTypeContainsField = function (model, fieldName) { - var inputTypeName = model.singularName + "Input"; - var inputType = Context.getInstance().schema.getType(inputTypeName, false); + Transformer.inputTypeContainsField = function (model, fieldName, action) { + var context = Context.getInstance(); + var inputTypeName = context.adapter.getInputTypeName(model, action); + var inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error("Type " + inputType + " doesn't exist."); return inputType.inputFields.find(function (f) { return f.name === fieldName; }) !== undefined; @@ -14999,6 +15003,7 @@ var VuexORMGraphQLPlugin = (function (exports) { * Builds a field for the GraphQL query and a specific model * * @param {Model|string} model The model to use + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Determines whether plural/nodes syntax or singular syntax is used. * @param {Arguments} args The args that will be passed to the query field ( user(role: $role) ) * @param {Array} path The relations in this list are ignored (while traversing relations). @@ -15011,7 +15016,7 @@ var VuexORMGraphQLPlugin = (function (exports) { * * @todo Do we need the allowIdFields param? */ - QueryBuilder.buildField = function (model, multiple, args, path, name, filter, allowIdFields) { + QueryBuilder.buildField = function (model, action, multiple, args, path, name, filter, allowIdFields) { if (multiple === void 0) { multiple = true; } if (path === void 0) { path = []; } if (filter === void 0) { filter = false; } @@ -15020,9 +15025,9 @@ var VuexORMGraphQLPlugin = (function (exports) { model = context.getModel(model); name = name ? name : model.pluralName; var field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); - var params = this.buildArguments(model, args, false, filter, allowIdFields, field); + var params = this.buildArguments(model, action, args, false, filter, allowIdFields, field); path = path.length === 0 ? [model.singularName] : path; - var fields = "\n " + model.getQueryFields().join(" ") + "\n " + this.buildRelationsQuery(model, path) + "\n "; + var fields = "\n " + model.getQueryFields().join(" ") + "\n " + this.buildRelationsQuery(model, path, action) + "\n "; if (multiple) { var header = "" + name + params; if (context.connectionMode === exports.ConnectionMode.NODES) { @@ -15047,13 +15052,14 @@ var VuexORMGraphQLPlugin = (function (exports) { * Currently only one root field for the query is possible. * @param {string} type 'mutation' or 'query' * @param {Model | string} model The model this query or mutation affects. This mainly determines the query fields. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {string} name Optional name of the query/mutation. Will overwrite the name from the model. * @param {Arguments} args Arguments for the query * @param {boolean} multiple Determines if the root query field is a connection or not (will be passed to buildField) * @param {boolean} filter When true the query arguments are passed via a filter object. * @returns {any} Whatever gql() returns */ - QueryBuilder.buildQuery = function (type, model, name, args, multiple, filter) { + QueryBuilder.buildQuery = function (type, model, action, name, args, multiple, filter) { var context = Context.getInstance(); // model model = context.getModel(model); @@ -15067,8 +15073,8 @@ var VuexORMGraphQLPlugin = (function (exports) { // field var field = context.schema.getMutation(name, true) || context.schema.getQuery(name, true); // build query - var query = type + " " + upcaseFirstLetter(name) + this.buildArguments(model, args, true, filter, true, field) + " {\n" + - (" " + this.buildField(model, multiple, args, [], name, filter, true) + "\n") + + var query = type + " " + upcaseFirstLetter(name) + this.buildArguments(model, action, args, true, filter, true, field) + " {\n" + + (" " + this.buildField(model, action, multiple, args, [], name, filter, true) + "\n") + "}"; return src(query); }; @@ -15090,6 +15096,7 @@ var VuexORMGraphQLPlugin = (function (exports) { * => 'users(filter: { active: $active })' * * @param model + * @param {string} action Name of the current action like 'persist' or 'push' * @param {Arguments | undefined} args * @param {boolean} signature When true, then this method generates a query signature instead of key/value pairs * @param filter @@ -15097,7 +15104,7 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {GraphQLField} field Optional. The GraphQL mutation or query field * @returns {String} */ - QueryBuilder.buildArguments = function (model, args, signature, filter, allowIdFields, field) { + QueryBuilder.buildArguments = function (model, action, args, signature, filter, allowIdFields, field) { var _this = this; if (signature === void 0) { signature = false; } if (filter === void 0) { filter = false; } @@ -15121,7 +15128,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type)) + "!"; + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; } else if (value instanceof Array && field) { var arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15240,9 +15247,10 @@ var VuexORMGraphQLPlugin = (function (exports) { * * @param {Model} model * @param {Array} path + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - QueryBuilder.buildRelationsQuery = function (model, path) { + QueryBuilder.buildRelationsQuery = function (model, path, action) { var _this = this; if (path === void 0) { path = []; } if (model === null) @@ -15263,7 +15271,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (model.shouldEagerLoadRelation(name, field, relatedModel) && !ignore) { var newPath = path.slice(0); newPath.push(relatedModel.singularName); - relationQueries.push(_this.buildField(relatedModel, Model.isConnection(field), undefined, newPath, name, false)); + relationQueries.push(_this.buildField(relatedModel, action, Model.isConnection(field), undefined, newPath, name, false)); } }); return relationQueries.join("\n"); @@ -15352,10 +15360,11 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {Data | undefined} variables Variables to send with the mutation * @param {Function} dispatch Vuex Dispatch method for the model * @param {Model} model The model this mutation affects. + * @param {string} action Name of the current action like 'persist' or 'push' * @param {boolean} multiple Tells if we're requesting a single record or multiple. * @returns {Promise} */ - Action.mutation = function (name, variables, dispatch, model) { + Action.mutation = function (name, variables, dispatch, model, action) { return __awaiter(this, void 0, void 0, function () { var context, schema, multiple, query, newData, insertedData, records, newRecord; var _a; @@ -15368,7 +15377,7 @@ var VuexORMGraphQLPlugin = (function (exports) { case 1: schema = _b.sent(); multiple = Schema.returnsConnection(schema.getMutation(name)); - query = QueryBuilder.buildQuery("mutation", model, name, variables, multiple); + query = QueryBuilder.buildQuery("mutation", model, action, name, variables, multiple); return [4 /*yield*/, context.apollo.request(model, query, variables, true)]; case 2: newData = _b.sent(); @@ -15422,24 +15431,26 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {Arguments} args * @param {Model} model * @param {Data} data + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.addRecordToArgs = function (args, model, data) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false); + Action.addRecordToArgs = function (args, model, data, action) { + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); return args; }; /** * Transforms each field of the args which contains a model. * @param {Arguments} args + * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.transformArgs = function (args) { + Action.transformArgs = function (args, action) { var context = Context.getInstance(); Object.keys(args).forEach(function (key) { var value = args[key]; if (value instanceof context.components.Model) { var model = context.getModel(singularize(value.$self().entity)); - var transformedValue = Transformer.transformOutgoingData(model, value, false); + var transformedValue = Transformer.transformOutgoingData(model, value, false, action); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15495,13 +15506,14 @@ var VuexORMGraphQLPlugin = (function (exports) { var state = _a.state, dispatch = _a.dispatch; var id = _b.id, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, mockReturnValue; + var model, mutationName, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!id) return [3 /*break*/, 4]; model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForDestroy(model); + action = 'destroy'; mockReturnValue = model.$mockHook("destroy", { id: id }); if (!mockReturnValue) return [3 /*break*/, 2]; return [4 /*yield*/, Store.insertData(mockReturnValue, dispatch)]; @@ -15510,7 +15522,7 @@ var VuexORMGraphQLPlugin = (function (exports) { return [2 /*return*/, true]; case 2: args = this.prepareArgs(args, id); - return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model)]; + return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 3: _c.sent(); return [2 /*return*/, true]; @@ -15561,12 +15573,13 @@ var VuexORMGraphQLPlugin = (function (exports) { Fetch.call = function (_a, params) { var state = _a.state, dispatch = _a.dispatch; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue, filter, bypassCache, multiple, name, query, data; + var context, model, action, mockReturnValue, filter, bypassCache, multiple, name, query, data; return __generator(this, function (_b) { switch (_b.label) { case 0: context = Context.getInstance(); model = this.getModelFromState(state); + action = 'fetch'; mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} }); @@ -15578,12 +15591,12 @@ var VuexORMGraphQLPlugin = (function (exports) { _b.sent(); filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); } bypassCache = params && params.bypassCache; multiple = !filter["id"]; name = context.adapter.getNameForFetch(model, multiple); - query = QueryBuilder.buildQuery("query", model, name, filter, multiple, multiple); + query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, multiple); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; case 2: data = _b.sent(); @@ -15643,13 +15656,14 @@ var VuexORMGraphQLPlugin = (function (exports) { var state = _a.state, dispatch = _a.dispatch; var args = _b.args, name = _b.name; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue; + var context, model, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!name) return [3 /*break*/, 2]; context = Context.getInstance(); model = this.getModelFromState(state); + action = 'mutate'; mockReturnValue = model.$mockHook("mutate", { name: name, args: args || {} @@ -15663,9 +15677,9 @@ var VuexORMGraphQLPlugin = (function (exports) { args = this.prepareArgs(args); // There could be anything in the args, but we have to be sure that all records are gone through // transformOutgoingData() - this.transformArgs(args); + this.transformArgs(args, action); // Send the mutation - return [2 /*return*/, Action.mutation(name, args, dispatch, model)]; + return [2 /*return*/, Action.mutation(name, args, dispatch, model, action)]; case 2: /* istanbul ignore next */ throw new Error("The mutate action requires the mutation name ('mutation') to be set"); @@ -15709,7 +15723,7 @@ var VuexORMGraphQLPlugin = (function (exports) { var state = _a.state, dispatch = _a.dispatch; var id = _b.id, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, oldRecord, mockReturnValue, newRecord_1, newRecord; + var model, mutationName, oldRecord, action, mockReturnValue, newRecord_1, newRecord; return __generator(this, function (_c) { switch (_c.label) { case 0: @@ -15717,6 +15731,7 @@ var VuexORMGraphQLPlugin = (function (exports) { model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForPersist(model); oldRecord = model.getRecordWithId(id); + action = 'persist'; mockReturnValue = model.$mockHook("persist", { id: toNumber(id), args: args || {} @@ -15736,8 +15751,8 @@ var VuexORMGraphQLPlugin = (function (exports) { // Arguments _c.sent(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord); - return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model)]; + this.addRecordToArgs(args, model, oldRecord, action); + return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 5: newRecord = _c.sent(); // Delete the old record if necessary @@ -15809,13 +15824,14 @@ var VuexORMGraphQLPlugin = (function (exports) { var state = _a.state, dispatch = _a.dispatch; var data = _b.data, args = _b.args; return __awaiter(this, void 0, void 0, function () { - var model, mutationName, mockReturnValue; + var model, mutationName, action, mockReturnValue; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!data) return [3 /*break*/, 2]; model = this.getModelFromState(state); mutationName = Context.getInstance().adapter.getNameForPush(model); + action = 'push'; mockReturnValue = model.$mockHook("push", { data: data, args: args || {} @@ -15829,9 +15845,9 @@ var VuexORMGraphQLPlugin = (function (exports) { // Arguments _c.sent(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data); + this.addRecordToArgs(args, model, data, action); // Send the mutation - return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model)]; + return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 2: /* istanbul ignore next */ throw new Error("The persist action requires the 'data' to be set"); @@ -15892,13 +15908,14 @@ var VuexORMGraphQLPlugin = (function (exports) { var state = _a.state, dispatch = _a.dispatch; var name = _b.name, filter = _b.filter, bypassCache = _b.bypassCache; return __awaiter(this, void 0, void 0, function () { - var context, model, mockReturnValue, schema, multiple, query, data; + var context, model, action, mockReturnValue, schema, multiple, query, data; return __generator(this, function (_c) { switch (_c.label) { case 0: if (!name) return [3 /*break*/, 3]; context = Context.getInstance(); model = this.getModelFromState(state); + action = 'query'; mockReturnValue = model.$mockHook("query", { name: name, filter: filter || {} @@ -15910,9 +15927,9 @@ var VuexORMGraphQLPlugin = (function (exports) { case 1: schema = _c.sent(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; multiple = Schema.returnsConnection(schema.getQuery(name)); - query = QueryBuilder.buildQuery("query", model, name, filter, multiple, false); + query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; case 2: data = _c.sent(); diff --git a/dist/vuex-orm-graphql.global.prod.js b/dist/vuex-orm-graphql.global.prod.js index d37ab736..708d0904 100644 --- a/dist/vuex-orm-graphql.global.prod.js +++ b/dist/vuex-orm-graphql.global.prod.js @@ -12,4 +12,4 @@ var VuexORMGraphQLPlugin=function(e){"use strict"; See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. - ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+W(e.values,", ")+"]"},ObjectValue:function(e){return"{"+W(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",W(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return W(["schema",W(t," "),J(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return W(["scalar",e.name,W(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+": "+r+H(" ",W(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return W([t+": "+n,H("= ",r),W(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["interface",t,W(n," "),J(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return W(["union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return W(["enum",t,W(n," "),J(r)]," ")})),EnumValueDefinition:Y((function(e){return W([e.name,W(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["input",t,W(n," "),J(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return W(["extend schema",W(t," "),J(n)]," ")},ScalarTypeExtension:function(e){return W(["extend scalar",e.name,W(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["extend type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend interface",t,W(n," "),J(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return W(["extend union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return W(["extend enum",t,W(n," "),J(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend input",t,W(n," "),J(r)]," ")}};function Y(e){return function(t){return W([t.description,e(t)],"\n")}}function W(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function J(e){return e&&0!==e.length?"{\n"+X(W(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=_r.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=_r.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",me(e)).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=_r.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof _r.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),Ee=Object.setPrototypeOf,we=void 0===Ee?function(e,t){return e.__proto__=t,e}:Ee,_e=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",we(r,t.prototype),r}return n(t,e),t}(Error);function Oe(e,t){if(!e)throw new _e(t)}function ke(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=ke("warn"),e.error=ke("error")}(Oe||(Oe={}));var Ne={env:{}};if("object"==typeof process)Ne=process;else try{Function("stub","process = stub")(Ne)}catch(e){}var Se=Object.prototype,Te=Se.toString,Ie=Se.hasOwnProperty,xe=new Map;function De(e,t){try{return function e(t,n){if(t===n)return!0;var r=Te.call(t),i=Te.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(Ae(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Ue(e){return e&&Be(["client"],e)&&Be(["export"],e)}function Ge(e){var t=e.name.value;return"skip"===t||"include"===t}function ze(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new _e(5):new _e("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?Oe(1===i.length,6):Oe(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function Ke(e){for(var t=[],n=1;n1){var r=[];t=wt(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var $t,Bt=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Lt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}($t||($t={}));var Ut=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=We(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Qt.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Lt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new Bt({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:Pt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Qt.loading:Qt.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&De(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new _e(3):new _e("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),De(this.variables,e)||(this.variables=r(r({},this.variables),e)),De(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),$t.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Oe(e.updateQuery,4):Oe(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,$t.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Oe.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&De(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=ht((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){Kt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:lt(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Gt)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(Kt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Qt.error,loading:!1})),zt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!De(a,i)?e.refetch():zt(e.observers,"next",n)})):zt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Vt);function Gt(e){"production"===process.env.NODE_ENV||Oe.error("Unhandled error",e.message,e.stack)}function zt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function Kt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Oe("cache-first"!==t&&"cache-only"!==t,5):Oe("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Wt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Oe(!t||t.document===e.document||De(t.document,e.document),19):Oe(!t||t.document===e.document||De(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Qt.loading&&(De(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Qt.setVariables:e.isPoll?Qt.poll:e.isRefetch?Qt.refetch:Qt.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Qt.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Lt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Qt.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Qt.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Qt.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Qt.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Qt.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=mt(t.resolvers,e)})):this.resolvers=mt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(Be(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Oe.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ye(e);var t=ot([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qe(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Oe(!1,6):Oe(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:st(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=Xe(e),c=He(e),l=Ze(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return $e(e,s)?Qe(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[Ce(e)]=t,n))}))]:(qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?Oe(i,7):Oe(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return gt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=Ce(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,je(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Ht(e){var t=new Set,n=null;return new Vt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Xt=Object.prototype.hasOwnProperty,Zt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Yt,this.queryStore=new Wt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(ut?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(8):new _e("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?Oe(t,9):Oe(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Oe(!v||"no-cache"===v,10):Oe(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Xt.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){dt(r)&&"none"===d?h=new Bt({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new Bt({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Lt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&dt(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,Be(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===$t.poll,isRefetch:n===$t.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new Bt({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||Oe.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Oe.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=Pt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Lt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new Bt({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new Bt({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),ot([at],Ye(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Ue(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:et(We(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Oe("standby"!==e.fetchPolicy,11):Oe("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Ut({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Oe(e.query,12):Oe(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Oe("Document"===e.query.kind,13):Oe("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Oe(!e.returnPartialData,14):Oe(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Oe(!e.pollInterval,15):Oe(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(16):new _e("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||Oe.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),dt(i))throw new Bt({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Vt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Oe(n,17):Oe(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Ht(Ct(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Ht(Ct(c,l))}else o=Vt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Vt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Lt(e.errors))return l(new Bt({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Qt.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Qt.ready&&t.networkStatus!==Qt.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?Oe(o,18):Oe(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,$t.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),en=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!dt(e);i&&dt(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){dt(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!dt(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=ht((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&ht((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),tn=!1,nn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=jt.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new _e(1):new _e("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new en(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),tn||"production"===process.env.NODE_ENV||(tn=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Zt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Oe("cache-and-network"!==e.fetchPolicy,2):Oe("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Ct(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Oe.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function rn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(e)}]}}function on(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return on(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:on(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var an={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},sn=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:ze(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:ze(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:an})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(t)}]}),data:s})}else this.writeQuery({query:rn(i),data:i})},e}(),un=null,cn={},ln=1,fn=Array,pn=fn["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",ln++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=un;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===cn)break;return e!==un&&(un.slots[this.id]=t),!0}return un&&(un.slots[this.id]=cn),!1},e.prototype.getValue=function(){if(this.hasValue())return un.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=un;un={parent:a,slots:o};try{return t.apply(r,n)}finally{un=a}},e.bind=function(e){var t=un;return function(){var n=un;try{return un=t,e.apply(this,arguments)}finally{un=n}}},e.noContext=function(e,t,n){if(!un)return e.apply(n,t);var r=un;try{return un=null,e.apply(n,t)}finally{un=r}},e}();try{Object.defineProperty(fn,"@wry/context:Slot",{value:fn["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();pn.bind,pn.noContext;function hn(){}var dn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=hn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),vn=new pn,yn=[],mn=[];function gn(e,t){if(!e)throw new Error(t||"assertion failure")}function bn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var En=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(gn(!this.recomputing,"already recomputing"),function(e){var t=vn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),_n(e)?Nn(t,e):Sn(t,e),t}(this)||!In(this))return _n(this)?function(e){var t=xn(e);vn.withValue(e,wn,[e]),function(e){if("function"==typeof e.subscribe)try{An(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,_n(e))return;kn(e)}(e);return t.forEach(In),bn(e.value)}(this):bn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,On(this),An(this))},e.prototype.dispose=function(){var e=this;xn(this).forEach(In),An(this),this.parents.forEach((function(t){t.setDirty(),Dn(t,e)}))},e.count=0,e}();function wn(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function _n(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e){e.parents.forEach((function(t){return Sn(t,e)}))}function Nn(e,t){if(gn(e.childValues.has(t)),gn(_n(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=mn.pop()||new Set;e.dirtyChildren.add(t),On(e)}function Sn(e,t){gn(e.childValues.has(t)),gn(!_n(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Tn(e,t),_n(e)||kn(e)}function Tn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(mn.length<100&&mn.push(n),e.dirtyChildren=null))}function In(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function xn(e){var t=yn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){Dn(e,r),t.push(r)}))),gn(null===e.dirtyChildren),t}function Dn(e,t){t.parents.delete(e),e.childValues.delete(t),Tn(e,t)}function An(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var Rn=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new _e(8):new _e("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&De(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Gn:o,s=Xe(t),u={query:t,fragmentMap:Ze(He(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if($e(e,u))if(Qe(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[Ce(e)]=c,n))}else{var d=void 0;if(qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new _e(9):new _e("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=gt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Fe(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Ve({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,je(n,i),o,{resultKey:Ce(n),directives:Le(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Un(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&vt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Hn={fragmentMatcher:new Pn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Xn=Object.prototype.hasOwnProperty,Zn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Xn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(zn),er=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new Rn(ut),n.silenceBroadcast=!1,n.config=r(r({},Hn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||Oe.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||Oe.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Ln:new zn,n.optimisticData=n.data,n.storeWriter=new Yn,n.storeReader=new Bn({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=Cn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Ln?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new _e(1):new _e("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Zn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Zn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ye(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Qe(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Qe(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[nt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(sn),tr={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},nr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},rr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new _e(2):new _e("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},ir=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&nr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||nr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var or,ar,sr=function(e){function t(t){return e.call(this,ir(t).request)||this}return n(t,e),t}(jt);(or=e.ConnectionMode||(e.ConnectionMode={}))[or.AUTO=0]="AUTO",or[or.PLAIN=1]="PLAIN",or[or.NODES=2]="NODES",or[or.EDGES=3]="EDGES",or[or.ITEMS=4]="ITEMS",(ar=e.ArgumentMode||(e.ArgumentMode={}))[ar.TYPE=0]="TYPE",ar[ar.LIST=1]="LIST";var ur,cr=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o){var a=this,s=_r.getInstance(),u=e.getRelations(),c={};return void 0===i&&(i=new Map),void 0===o&&(o=!1),Object.keys(t).forEach((function(l){var f=t[l],p=e.getRelations().has(l);if(!(f instanceof Array?p&&a.isRecursion(i,f[0]):p&&a.isRecursion(i,f))&&a.shouldIncludeOutgoingField(o&&n,l,f,e,r)){var h=be.getRelatedModel(u.get(l));if(f instanceof Array){var d=s.getModel(se(l),!0);d?(a.addRecordForRecursionDetection(i,f[0]),c[l]=f.map((function(t){return a.transformOutgoingData(d||e,t,n,void 0,i,!0)}))):c[l]=f}else"object"==typeof f&&void 0!==f.$id?(h||(h=s.getModel(f.$self().entity)),a.addRecordForRecursionDetection(i,f),c[l]=a.transformOutgoingData(h,f,n,void 0,i,!0)):c[l]=f}})),c},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=_r.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else if(t[u].items&&s.connectionMode===e.ConnectionMode.ITEMS)a[ae(u)]=o.transformIncomingData(t[u].items,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else be.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i){if(i&&i.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(!this.inputTypeContainsField(r,t))return!1;if(r.getRelations().has(t)){if(e)return!1;var o=r.getRelations().get(t),a=be.getRelatedModel(o);return!(!a||!r.shouldEagerSaveRelation(t,o,a))}return!0},t.inputTypeContainsField=function(e,t){var n=e.singularName+"Input",r=_r.getInstance().schema.getType(n,!1);if(null===r)throw new Error("Type "+r+" doesn't exist.");return void 0!==r.inputFields.find((function(e){return e.name===t}))},t.addRecordForRecursionDetection=function(e,t){var n=_r.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return _r.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=_r.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),lr=((ur=V)&&ur.default||ur).parse;function fr(e){return e.replace(/[\s,]+/g," ").trim()}var pr={},hr={};var dr=!0;var vr=!1;function yr(e){var t=fr(e);if(pr[t])return pr[t];var n=lr(e,{experimentalFragmentVariables:vr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(a.singularName);if(e.shouldEagerLoadRelation(o,i,a)&&!u){var c=t.slice(0);c.push(a.singularName),r.push(n.buildField(a,be.isConnection(i),void 0,c,o,!1))}})),r.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(_r.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),kr=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],_r.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),Nr=function(){function e(){}return e.mutation=function(e,t,n,r){return i(this,void 0,void 0,(function(){var i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=_r.getInstance()).loadSchema()]:[3,5];case 1:return a=o.sent(),s=Er.returnsConnection(a.getMutation(e)),u=Or.buildQuery("mutation",r,e,t,s),[4,i.apollo.request(r,u,t,!0)];case 2:return c=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((c=c[Object.keys(c)[0]]).id=me(c.id),[4,kr.insertData((h={},h[r.pluralName]=c,h),n)]);case 3:return l=o.sent(),f=l[r.pluralName],(p=f[f.length-1])?[2,p]:(_r.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",l,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return _r.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n){return e[t.singularName]=cr.transformOutgoingData(t,n,!1),e},e.transformArgs=function(e){var t=_r.getInstance();return Object.keys(e).forEach((function(n){var r=e[n];if(r instanceof t.components.Model){var i=t.getModel(se(r.$self().entity)),o=cr.transformOutgoingData(i,r,!1);t.logger.log("A",n,"model was found within the variables and will be transformed from",r,"to",o),e[n]=o}})),e},e}(),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.destroy=t.call.bind(t),n.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:me(this.$id)})]}))}))},n.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForDestroy(e),(i=e.$mockHook("destroy",{id:a}))?[4,kr.insertData(i,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,Nr.mutation(t,s,r,e)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(Nr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model;e.components.Actions.fetch=t.call.bind(t),n.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),i=this.getModelFromState(n),(a=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,kr.insertData(a,r)]:[4,e.loadSchema()];case 1:return o.sent(),s={},t&&t.filter&&(s=cr.transformOutgoingData(i,t.filter,!0,Object.keys(t.filter))),u=t&&t.bypassCache,c=!s.id,l=e.adapter.getNameForFetch(i,c),f=Or.buildQuery("query",i,l,s,c,c),[4,e.apollo.request(i,f,s,!1,u)];case 2:return p=o.sent(),[2,kr.insertData(p,r)]}}))}))},t}(Nr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.mutate=t.call.bind(t),n.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},r.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return s?(e=_r.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,kr.insertData(i,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a),[2,Nr.mutation(s,a,r,t)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(Nr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.persist=t.call.bind(t),n.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),(u=e.$mockHook("persist",{id:me(a),args:s||{}}))?[4,kr.insertData(u,r)]:[3,3]):[3,7];case 1:return c=o.sent(),[4,this.deleteObsoleteRecord(e,c,i)];case 2:return o.sent(),[2,c];case 3:return[4,_r.getInstance().loadSchema()];case 4:return o.sent(),s=this.prepareArgs(s),this.addRecordToArgs(s,e,i),[4,Nr.mutation(t,s,r,e)];case 5:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 6:return o.sent(),[2,l];case 7:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(_r.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(Nr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.push=t.call.bind(t),n.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPush(e),(i=e.$mockHook("push",{data:a,args:s||{}}))?[2,kr.insertData(i,r)]:[4,_r.getInstance().loadSchema()]):[3,2];case 1:return o.sent(),s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a),[2,Nr.mutation(t,s,r,e)];case 2:throw new Error("The persist action requires the 'data' to be set")}}))}))},t}(Nr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.query=t.call.bind(t),n.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},r.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p;return o(this,(function(o){switch(o.label){case 0:return a?(e=_r.getInstance(),t=this.getModelFromState(n),(i=t.$mockHook("query",{name:a,filter:s||{}}))?[2,kr.insertData(i,r)]:[4,e.loadSchema()]):[3,3];case 1:return c=o.sent(),s=s?cr.transformOutgoingData(t,s,!0):{},l=Er.returnsConnection(c.getQuery(a)),f=Or.buildQuery("query",t,a,s,l,!1),[4,e.apollo.request(t,f,s,!1,u)];case 2:return p=o.sent(),[2,kr.insertData(p,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(Nr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleQuery=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(Nr),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleMutation=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(Nr),Fr=function(){function e(t,n){_r.setup(t,n),e.setupActions()}return e.prototype.getContext=function(){return _r.getInstance()},e.setupActions=function(){Tr.setup(),xr.setup(),Dr.setup(),Sr.setup(),Ir.setup(),Ar.setup(),Rr.setup(),Mr.setup()},e}(),jr=function(){function e(){}return e.install=function(t,n){return e.instance=new Fr(t,n),e.instance},e}(),Cr=null;var Qr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?Cr.addGlobalMock(this):Cr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=wr,e.Mock=Qr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!Cr)throw new Error("Please call setupTestUtils() before!");return[4,Cr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=jr,e.mock=function(e,t){if(!Cr)throw new Error("Please call setupTestUtils() before!");return new Qr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");Cr=e.instance.getContext()},e}({}); + ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+W(e.values,", ")+"]"},ObjectValue:function(e){return"{"+W(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",W(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return W(["schema",W(t," "),J(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return W(["scalar",e.name,W(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+": "+r+H(" ",W(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return W([t+": "+n,H("= ",r),W(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["interface",t,W(n," "),J(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return W(["union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return W(["enum",t,W(n," "),J(r)]," ")})),EnumValueDefinition:Y((function(e){return W([e.name,W(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["input",t,W(n," "),J(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return W(["extend schema",W(t," "),J(n)]," ")},ScalarTypeExtension:function(e){return W(["extend scalar",e.name,W(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["extend type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend interface",t,W(n," "),J(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return W(["extend union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return W(["extend enum",t,W(n," "),J(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend input",t,W(n," "),J(r)]," ")}};function Y(e){return function(t){return W([t.description,e(t)],"\n")}}function W(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function J(e){return e&&0!==e.length?"{\n"+X(W(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=_r.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=_r.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",me(e)).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=_r.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof _r.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),Ee=Object.setPrototypeOf,we=void 0===Ee?function(e,t){return e.__proto__=t,e}:Ee,_e=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",we(r,t.prototype),r}return n(t,e),t}(Error);function Oe(e,t){if(!e)throw new _e(t)}function ke(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=ke("warn"),e.error=ke("error")}(Oe||(Oe={}));var Ne={env:{}};if("object"==typeof process)Ne=process;else try{Function("stub","process = stub")(Ne)}catch(e){}var Se=Object.prototype,Te=Se.toString,Ie=Se.hasOwnProperty,xe=new Map;function De(e,t){try{return function e(t,n){if(t===n)return!0;var r=Te.call(t),i=Te.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(Ae(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Ue(e){return e&&Be(["client"],e)&&Be(["export"],e)}function Ge(e){var t=e.name.value;return"skip"===t||"include"===t}function ze(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new _e(5):new _e("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?Oe(1===i.length,6):Oe(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function Ke(e){for(var t=[],n=1;n1){var r=[];t=wt(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var $t,Bt=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Lt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}($t||($t={}));var Ut=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=We(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Qt.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Lt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new Bt({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:Pt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Qt.loading:Qt.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&De(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new _e(3):new _e("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),De(this.variables,e)||(this.variables=r(r({},this.variables),e)),De(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),$t.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Oe(e.updateQuery,4):Oe(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,$t.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Oe.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&De(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=ht((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){Kt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:lt(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Gt)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(Kt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Qt.error,loading:!1})),zt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!De(a,i)?e.refetch():zt(e.observers,"next",n)})):zt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Vt);function Gt(e){"production"===process.env.NODE_ENV||Oe.error("Unhandled error",e.message,e.stack)}function zt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function Kt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Oe("cache-first"!==t&&"cache-only"!==t,5):Oe("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Wt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Oe(!t||t.document===e.document||De(t.document,e.document),19):Oe(!t||t.document===e.document||De(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Qt.loading&&(De(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Qt.setVariables:e.isPoll?Qt.poll:e.isRefetch?Qt.refetch:Qt.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Qt.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Lt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Qt.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Qt.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Qt.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Qt.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Qt.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=mt(t.resolvers,e)})):this.resolvers=mt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(Be(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Oe.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ye(e);var t=ot([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qe(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Oe(!1,6):Oe(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:st(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=Xe(e),c=He(e),l=Ze(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return $e(e,s)?Qe(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[Ce(e)]=t,n))}))]:(qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?Oe(i,7):Oe(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return gt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=Ce(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,je(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Ht(e){var t=new Set,n=null;return new Vt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Xt=Object.prototype.hasOwnProperty,Zt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Yt,this.queryStore=new Wt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(ut?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(8):new _e("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?Oe(t,9):Oe(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Oe(!v||"no-cache"===v,10):Oe(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Xt.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){dt(r)&&"none"===d?h=new Bt({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new Bt({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Lt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&dt(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,Be(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===$t.poll,isRefetch:n===$t.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new Bt({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||Oe.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Oe.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=Pt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Lt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new Bt({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new Bt({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),ot([at],Ye(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Ue(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:et(We(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Oe("standby"!==e.fetchPolicy,11):Oe("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Ut({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Oe(e.query,12):Oe(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Oe("Document"===e.query.kind,13):Oe("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Oe(!e.returnPartialData,14):Oe(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Oe(!e.pollInterval,15):Oe(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(16):new _e("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||Oe.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),dt(i))throw new Bt({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Vt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Oe(n,17):Oe(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Ht(Ct(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Ht(Ct(c,l))}else o=Vt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Vt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Lt(e.errors))return l(new Bt({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Qt.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Qt.ready&&t.networkStatus!==Qt.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?Oe(o,18):Oe(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,$t.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),en=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!dt(e);i&&dt(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){dt(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!dt(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=ht((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&ht((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),tn=!1,nn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=jt.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new _e(1):new _e("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new en(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),tn||"production"===process.env.NODE_ENV||(tn=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Zt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Oe("cache-and-network"!==e.fetchPolicy,2):Oe("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Ct(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Oe.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function rn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(e)}]}}function on(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return on(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:on(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var an={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},sn=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:ze(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:ze(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:an})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(t)}]}),data:s})}else this.writeQuery({query:rn(i),data:i})},e}(),un=null,cn={},ln=1,fn=Array,pn=fn["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",ln++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=un;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===cn)break;return e!==un&&(un.slots[this.id]=t),!0}return un&&(un.slots[this.id]=cn),!1},e.prototype.getValue=function(){if(this.hasValue())return un.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=un;un={parent:a,slots:o};try{return t.apply(r,n)}finally{un=a}},e.bind=function(e){var t=un;return function(){var n=un;try{return un=t,e.apply(this,arguments)}finally{un=n}}},e.noContext=function(e,t,n){if(!un)return e.apply(n,t);var r=un;try{return un=null,e.apply(n,t)}finally{un=r}},e}();try{Object.defineProperty(fn,"@wry/context:Slot",{value:fn["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();pn.bind,pn.noContext;function hn(){}var dn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=hn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),vn=new pn,yn=[],mn=[];function gn(e,t){if(!e)throw new Error(t||"assertion failure")}function bn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var En=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(gn(!this.recomputing,"already recomputing"),function(e){var t=vn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),_n(e)?Nn(t,e):Sn(t,e),t}(this)||!In(this))return _n(this)?function(e){var t=xn(e);vn.withValue(e,wn,[e]),function(e){if("function"==typeof e.subscribe)try{An(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,_n(e))return;kn(e)}(e);return t.forEach(In),bn(e.value)}(this):bn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,On(this),An(this))},e.prototype.dispose=function(){var e=this;xn(this).forEach(In),An(this),this.parents.forEach((function(t){t.setDirty(),Dn(t,e)}))},e.count=0,e}();function wn(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function _n(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e){e.parents.forEach((function(t){return Sn(t,e)}))}function Nn(e,t){if(gn(e.childValues.has(t)),gn(_n(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=mn.pop()||new Set;e.dirtyChildren.add(t),On(e)}function Sn(e,t){gn(e.childValues.has(t)),gn(!_n(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Tn(e,t),_n(e)||kn(e)}function Tn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(mn.length<100&&mn.push(n),e.dirtyChildren=null))}function In(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function xn(e){var t=yn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){Dn(e,r),t.push(r)}))),gn(null===e.dirtyChildren),t}function Dn(e,t){t.parents.delete(e),e.childValues.delete(t),Tn(e,t)}function An(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var Rn=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new _e(8):new _e("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&De(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Gn:o,s=Xe(t),u={query:t,fragmentMap:Ze(He(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if($e(e,u))if(Qe(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[Ce(e)]=c,n))}else{var d=void 0;if(qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new _e(9):new _e("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=gt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Fe(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Ve({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,je(n,i),o,{resultKey:Ce(n),directives:Le(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Un(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&vt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Hn={fragmentMatcher:new Pn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Xn=Object.prototype.hasOwnProperty,Zn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Xn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(zn),er=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new Rn(ut),n.silenceBroadcast=!1,n.config=r(r({},Hn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||Oe.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||Oe.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Ln:new zn,n.optimisticData=n.data,n.storeWriter=new Yn,n.storeReader=new Bn({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=Cn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Ln?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new _e(1):new _e("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Zn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Zn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ye(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Qe(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Qe(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[nt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(sn),tr={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},nr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},rr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new _e(2):new _e("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},ir=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&nr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||nr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var or,ar,sr=function(e){function t(t){return e.call(this,ir(t).request)||this}return n(t,e),t}(jt);(or=e.ConnectionMode||(e.ConnectionMode={}))[or.AUTO=0]="AUTO",or[or.PLAIN=1]="PLAIN",or[or.NODES=2]="NODES",or[or.EDGES=3]="EDGES",or[or.ITEMS=4]="ITEMS",(ar=e.ArgumentMode||(e.ArgumentMode={}))[ar.TYPE=0]="TYPE",ar[ar.LIST=1]="LIST";var ur,cr=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o,a){var s=this,u=_r.getInstance(),c=e.getRelations(),l={};return void 0===o&&(o=new Map),void 0===a&&(a=!1),Object.keys(t).forEach((function(f){var p=t[f],h=e.getRelations().has(f);if(!(p instanceof Array?h&&s.isRecursion(o,p[0]):h&&s.isRecursion(o,p))&&s.shouldIncludeOutgoingField(a&&n,f,p,e,r,i)){var d=be.getRelatedModel(c.get(f));if(p instanceof Array){var v=u.getModel(se(f),!0);v?(s.addRecordForRecursionDetection(o,p[0]),l[f]=p.map((function(t){return s.transformOutgoingData(v||e,t,n,r,void 0,o,!0)}))):l[f]=p}else"object"==typeof p&&void 0!==p.$id?(d||(d=u.getModel(p.$self().entity)),s.addRecordForRecursionDetection(o,p),l[f]=s.transformOutgoingData(d,p,n,r,void 0,o,!0)):l[f]=p}})),l},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=_r.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else if(t[u].items&&s.connectionMode===e.ConnectionMode.ITEMS)a[ae(u)]=o.transformIncomingData(t[u].items,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else be.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i,o){if(o&&o.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(!this.inputTypeContainsField(r,t,i))return!1;if(r.getRelations().has(t)){if(e)return!1;var a=r.getRelations().get(t),s=be.getRelatedModel(a);return!(!s||!r.shouldEagerSaveRelation(t,a,s))}return!0},t.inputTypeContainsField=function(e,t,n){var r=_r.getInstance(),i=r.adapter.getInputTypeName(e,n),o=r.schema.getType(i,!1);if(null===o)throw new Error("Type "+o+" doesn't exist.");return void 0!==o.inputFields.find((function(e){return e.name===t}))},t.addRecordForRecursionDetection=function(e,t){var n=_r.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return _r.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=_r.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),lr=((ur=V)&&ur.default||ur).parse;function fr(e){return e.replace(/[\s,]+/g," ").trim()}var pr={},hr={};var dr=!0;var vr=!1;function yr(e){var t=fr(e);if(pr[t])return pr[t];var n=lr(e,{experimentalFragmentVariables:vr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(s.singularName);if(e.shouldEagerLoadRelation(a,o,s)&&!c){var l=t.slice(0);l.push(s.singularName),i.push(r.buildField(s,n,be.isConnection(o),void 0,l,a,!1))}})),i.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(_r.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),kr=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],_r.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),Nr=function(){function e(){}return e.mutation=function(e,t,n,r,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=_r.getInstance()).loadSchema()]:[3,5];case 1:return s=o.sent(),u=Er.returnsConnection(s.getMutation(e)),c=Or.buildQuery("mutation",r,a,e,t,u),[4,i.apollo.request(r,c,t,!0)];case 2:return l=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((l=l[Object.keys(l)[0]]).id=me(l.id),[4,kr.insertData((d={},d[r.pluralName]=l,d),n)]);case 3:return f=o.sent(),p=f[r.pluralName],(h=p[p.length-1])?[2,h]:(_r.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",f,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return _r.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n,r){return e[t.singularName]=cr.transformOutgoingData(t,n,!1,r),e},e.transformArgs=function(e,t){var n=_r.getInstance();return Object.keys(e).forEach((function(r){var i=e[r];if(i instanceof n.components.Model){var o=n.getModel(se(i.$self().entity)),a=cr.transformOutgoingData(o,i,!1,t);n.logger.log("A",r,"model was found within the variables and will be transformed from",i,"to",a),e[r]=a}})),e},e}(),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.destroy=t.call.bind(t),n.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:me(this.$id)})]}))}))},n.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForDestroy(e),i="destroy",(u=e.$mockHook("destroy",{id:a}))?[4,kr.insertData(u,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,Nr.mutation(t,s,r,e,i)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(Nr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model;e.components.Actions.fetch=t.call.bind(t),n.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),i=this.getModelFromState(n),a="fetch",(s=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,kr.insertData(s,r)]:[4,e.loadSchema()];case 1:return o.sent(),u={},t&&t.filter&&(u=cr.transformOutgoingData(i,t.filter,!0,a,Object.keys(t.filter))),c=t&&t.bypassCache,l=!u.id,f=e.adapter.getNameForFetch(i,l),p=Or.buildQuery("query",i,a,f,u,l,l),[4,e.apollo.request(i,p,u,!1,c)];case 2:return h=o.sent(),[2,kr.insertData(h,r)]}}))}))},t}(Nr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.mutate=t.call.bind(t),n.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},r.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return s?(e=_r.getInstance(),t=this.getModelFromState(n),i="mutate",(u=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,kr.insertData(u,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a,i),[2,Nr.mutation(s,a,r,t,i)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(Nr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.persist=t.call.bind(t),n.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l,f;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),u="persist",(c=e.$mockHook("persist",{id:me(a),args:s||{}}))?[4,kr.insertData(c,r)]:[3,3]):[3,7];case 1:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 2:return o.sent(),[2,l];case 3:return[4,_r.getInstance().loadSchema()];case 4:return o.sent(),s=this.prepareArgs(s),this.addRecordToArgs(s,e,i,u),[4,Nr.mutation(t,s,r,e,u)];case 5:return f=o.sent(),[4,this.deleteObsoleteRecord(e,f,i)];case 6:return o.sent(),[2,f];case 7:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(_r.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(Nr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.push=t.call.bind(t),n.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPush(e),i="push",(u=e.$mockHook("push",{data:a,args:s||{}}))?[2,kr.insertData(u,r)]:[4,_r.getInstance().loadSchema()]):[3,2];case 1:return o.sent(),s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a,i),[2,Nr.mutation(t,s,r,e,i)];case 2:throw new Error("The persist action requires the 'data' to be set")}}))}))},t}(Nr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.query=t.call.bind(t),n.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},r.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return a?(e=_r.getInstance(),t=this.getModelFromState(n),i="query",(c=t.$mockHook("query",{name:a,filter:s||{}}))?[2,kr.insertData(c,r)]:[4,e.loadSchema()]):[3,3];case 1:return l=o.sent(),s=s?cr.transformOutgoingData(t,s,!0,i):{},f=Er.returnsConnection(l.getQuery(a)),p=Or.buildQuery("query",t,i,a,s,f,!1),[4,e.apollo.request(t,p,s,!1,u)];case 2:return h=o.sent(),[2,kr.insertData(h,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(Nr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleQuery=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(Nr),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleMutation=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(Nr),Fr=function(){function e(t,n){_r.setup(t,n),e.setupActions()}return e.prototype.getContext=function(){return _r.getInstance()},e.setupActions=function(){Tr.setup(),xr.setup(),Dr.setup(),Sr.setup(),Ir.setup(),Ar.setup(),Rr.setup(),Mr.setup()},e}(),jr=function(){function e(){}return e.install=function(t,n){return e.instance=new Fr(t,n),e.instance},e}(),Cr=null;var Qr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?Cr.addGlobalMock(this):Cr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=wr,e.Mock=Qr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!Cr)throw new Error("Please call setupTestUtils() before!");return[4,Cr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=jr,e.mock=function(e,t){if(!Cr)throw new Error("Please call setupTestUtils() before!");return new Qr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");Cr=e.instance.getContext()},e}({}); From 0a9d9c976c10b07edca7ca4159ffef1ed7bdcc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=CC=88llar=20Esinurm?= Date: Fri, 28 Aug 2020 14:45:06 +0300 Subject: [PATCH 3/3] Use mutation in getInputTypeName --- dist/actions/action.d.ts | 2 +- dist/adapters/adapter.d.ts | 2 +- dist/adapters/builtin/default-adapter.d.ts | 2 +- dist/graphql/transformer.d.ts | 6 ++-- dist/vuex-orm-graphql.cjs.js | 42 +++++++++++++--------- dist/vuex-orm-graphql.esm-bundler.js | 42 +++++++++++++--------- dist/vuex-orm-graphql.esm.js | 42 +++++++++++++--------- dist/vuex-orm-graphql.esm.prod.js | 42 +++++++++++++--------- dist/vuex-orm-graphql.global.js | 42 +++++++++++++--------- dist/vuex-orm-graphql.global.prod.js | 2 +- src/actions/action.ts | 19 ++++++++-- src/actions/fetch.ts | 3 +- src/actions/persist.ts | 5 +-- src/actions/push.ts | 4 +-- src/actions/query.ts | 6 ++-- src/adapters/adapter.ts | 2 +- src/adapters/builtin/default-adapter.ts | 2 +- src/graphql/query-builder.ts | 24 +++++++++++-- src/graphql/transformer.ts | 27 +++++++++----- 19 files changed, 202 insertions(+), 114 deletions(-) diff --git a/dist/actions/action.d.ts b/dist/actions/action.d.ts index 1c68f600..2269c77c 100644 --- a/dist/actions/action.d.ts +++ b/dist/actions/action.d.ts @@ -41,7 +41,7 @@ export default class Action { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string): Arguments; + static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string, mutationName: string): Arguments; /** * Transforms each field of the args which contains a model. * @param {Arguments} args diff --git a/dist/adapters/adapter.d.ts b/dist/adapters/adapter.d.ts index bd812188..d11f3b27 100644 --- a/dist/adapters/adapter.d.ts +++ b/dist/adapters/adapter.d.ts @@ -20,6 +20,6 @@ export default interface Adapter { getConnectionMode(): ConnectionMode; getArgumentMode(): ArgumentMode; getFilterTypeName(model: Model): string; - getInputTypeName(model: Model, action?: string): string; + getInputTypeName(model: Model, action?: string, mutation?: string): string; prepareSchemaTypeName(name: string): string; } diff --git a/dist/adapters/builtin/default-adapter.d.ts b/dist/adapters/builtin/default-adapter.d.ts index b63a1a83..d2b725d7 100644 --- a/dist/adapters/builtin/default-adapter.d.ts +++ b/dist/adapters/builtin/default-adapter.d.ts @@ -6,7 +6,7 @@ export default class DefaultAdapter implements Adapter { getConnectionMode(): ConnectionMode; getArgumentMode(): ArgumentMode; getFilterTypeName(model: Model): string; - getInputTypeName(model: Model, action?: string): string; + getInputTypeName(model: Model, action?: string, mutation?: string): string; getNameForDestroy(model: Model): string; getNameForFetch(model: Model, plural: boolean): string; getNameForPersist(model: Model): string; diff --git a/dist/graphql/transformer.d.ts b/dist/graphql/transformer.d.ts index 7ea7eace..888d953b 100644 --- a/dist/graphql/transformer.d.ts +++ b/dist/graphql/transformer.d.ts @@ -12,13 +12,14 @@ export default class Transformer { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model: Model, data: Data, read: boolean, action: string, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean): Data; + static transformOutgoingData(model: Model, data: Data, read: boolean, action: string, mutationName: string, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean): Data; /** * Transforms a set of incoming data to the format vuex-orm requires. * @@ -36,10 +37,11 @@ export default class Transformer { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, action: string, whitelist?: Array): boolean; + static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, action: string, mutationName: string, whitelist?: Array): boolean; /** * Tells whether a field is in the input type. * @param {Model} model diff --git a/dist/vuex-orm-graphql.cjs.js b/dist/vuex-orm-graphql.cjs.js index c48d2c8d..691d0dd2 100644 --- a/dist/vuex-orm-graphql.cjs.js +++ b/dist/vuex-orm-graphql.cjs.js @@ -14121,13 +14121,14 @@ var Transformer = /** @class */ (function () { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - Transformer.transformOutgoingData = function (model, data, read, action, whitelist, outgoingRecords, recursiveCall) { + Transformer.transformOutgoingData = function (model, data, read, action, mutationName, whitelist, outgoingRecords, recursiveCall) { var _this = this; var context = Context.getInstance(); var relations = model.getRelations(); @@ -14150,7 +14151,7 @@ var Transformer = /** @class */ (function () { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { + _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, mutationName, whitelist)) { var relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14158,7 +14159,7 @@ var Transformer = /** @class */ (function () { if (arrayModel_1) { _this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(function (v) { - return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, undefined, outgoingRecords, true); + return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, mutationName, undefined, outgoingRecords, true); }); } else { @@ -14172,7 +14173,7 @@ var Transformer = /** @class */ (function () { } _this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); + returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, mutationName, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14259,10 +14260,11 @@ var Transformer = /** @class */ (function () { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, whitelist) { + Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, mutationName, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14275,8 +14277,9 @@ var Transformer = /** @class */ (function () { // Ignore empty fields if (value === null || value === undefined) return false; + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14299,9 +14302,11 @@ var Transformer = /** @class */ (function () { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - Transformer.inputTypeContainsField = function (model, fieldName, action) { + Transformer.inputTypeContainsField = function (model, fieldName, action, mutationName) { var context = Context.getInstance(); - var inputTypeName = context.adapter.getInputTypeName(model, action); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + var inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 var inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error("Type " + inputType + " doesn't exist."); @@ -14754,7 +14759,7 @@ var DefaultAdapter = /** @class */ (function () { DefaultAdapter.prototype.getFilterTypeName = function (model) { return upcaseFirstLetter(model.singularName) + "Filter"; }; - DefaultAdapter.prototype.getInputTypeName = function (model, action) { + DefaultAdapter.prototype.getInputTypeName = function (model, action, mutation) { return upcaseFirstLetter(model.singularName) + "Input"; }; DefaultAdapter.prototype.getNameForDestroy = function (model) { @@ -15129,7 +15134,8 @@ var QueryBuilder = /** @class */ (function () { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action, field === null || field === void 0 ? void 0 : field.name) + "!"; //1 } else if (value instanceof Array && field) { var arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15435,8 +15441,9 @@ var Action = /** @class */ (function () { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.addRecordToArgs = function (args, model, data, action) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + Action.addRecordToArgs = function (args, model, data, action, mutationName) { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action, mutationName); return args; }; /** @@ -15451,7 +15458,7 @@ var Action = /** @class */ (function () { var value = args[key]; if (value instanceof context.components.Model) { var model = context.getModel(singularize(value.$self().entity)); - var transformedValue = Transformer.transformOutgoingData(model, value, false, action); + var transformedValue = Transformer.transformOutgoingData(model, value, false, action, ''); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15592,7 +15599,7 @@ var Fetch = /** @class */ (function (_super) { _b.sent(); filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, '', Object.keys(params.filter)); } bypassCache = params && params.bypassCache; multiple = !filter["id"]; @@ -15752,7 +15759,8 @@ var Persist = /** @class */ (function (_super) { // Arguments _c.sent(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 5: newRecord = _c.sent(); @@ -15846,7 +15854,7 @@ var Push = /** @class */ (function (_super) { // Arguments _c.sent(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 2: @@ -15928,7 +15936,7 @@ var Query = /** @class */ (function (_super) { case 1: schema = _c.sent(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action, '') : {}; multiple = Schema.returnsConnection(schema.getQuery(name)); query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; diff --git a/dist/vuex-orm-graphql.esm-bundler.js b/dist/vuex-orm-graphql.esm-bundler.js index fdb45c5e..7fb7eaed 100644 --- a/dist/vuex-orm-graphql.esm-bundler.js +++ b/dist/vuex-orm-graphql.esm-bundler.js @@ -14099,13 +14099,14 @@ class Transformer { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, mutationName, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14127,7 +14128,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, mutationName, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14135,7 +14136,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, mutationName, undefined, outgoingRecords, true); }); } else { @@ -14149,7 +14150,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, mutationName, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14233,10 +14234,11 @@ class Transformer { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, mutationName, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14249,8 +14251,9 @@ class Transformer { // Ignore empty fields if (value === null || value === undefined) return false; + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14273,9 +14276,11 @@ class Transformer { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName, action) { + static inputTypeContainsField(model, fieldName, action, mutationName) { const context = Context.getInstance(); - const inputTypeName = context.adapter.getInputTypeName(model, action); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + const inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); @@ -14691,7 +14696,7 @@ class DefaultAdapter { getFilterTypeName(model) { return `${upcaseFirstLetter(model.singularName)}Filter`; } - getInputTypeName(model, action) { + getInputTypeName(model, action, mutation) { return `${upcaseFirstLetter(model.singularName)}Input`; } getNameForDestroy(model) { @@ -15148,7 +15153,8 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action, field === null || field === void 0 ? void 0 : field.name) + "!"; //1 } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15415,8 +15421,9 @@ class Action { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data, action) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + static addRecordToArgs(args, model, data, action, mutationName) { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action, mutationName); return args; } /** @@ -15431,7 +15438,7 @@ class Action { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false, action); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action, ''); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15525,7 +15532,7 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, '', Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode @@ -15635,7 +15642,8 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); // Send mutation const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary @@ -15701,7 +15709,7 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return Action.mutation(mutationName, args, dispatch, model, action); } @@ -15758,7 +15766,7 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action, '') : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query diff --git a/dist/vuex-orm-graphql.esm.js b/dist/vuex-orm-graphql.esm.js index fdb45c5e..7fb7eaed 100644 --- a/dist/vuex-orm-graphql.esm.js +++ b/dist/vuex-orm-graphql.esm.js @@ -14099,13 +14099,14 @@ class Transformer { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, mutationName, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14127,7 +14128,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, mutationName, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14135,7 +14136,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, mutationName, undefined, outgoingRecords, true); }); } else { @@ -14149,7 +14150,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, mutationName, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14233,10 +14234,11 @@ class Transformer { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, mutationName, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14249,8 +14251,9 @@ class Transformer { // Ignore empty fields if (value === null || value === undefined) return false; + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14273,9 +14276,11 @@ class Transformer { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName, action) { + static inputTypeContainsField(model, fieldName, action, mutationName) { const context = Context.getInstance(); - const inputTypeName = context.adapter.getInputTypeName(model, action); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + const inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); @@ -14691,7 +14696,7 @@ class DefaultAdapter { getFilterTypeName(model) { return `${upcaseFirstLetter(model.singularName)}Filter`; } - getInputTypeName(model, action) { + getInputTypeName(model, action, mutation) { return `${upcaseFirstLetter(model.singularName)}Input`; } getNameForDestroy(model) { @@ -15148,7 +15153,8 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action, field === null || field === void 0 ? void 0 : field.name) + "!"; //1 } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15415,8 +15421,9 @@ class Action { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data, action) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + static addRecordToArgs(args, model, data, action, mutationName) { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action, mutationName); return args; } /** @@ -15431,7 +15438,7 @@ class Action { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false, action); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action, ''); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15525,7 +15532,7 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, '', Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode @@ -15635,7 +15642,8 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); // Send mutation const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary @@ -15701,7 +15709,7 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return Action.mutation(mutationName, args, dispatch, model, action); } @@ -15758,7 +15766,7 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action, '') : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query diff --git a/dist/vuex-orm-graphql.esm.prod.js b/dist/vuex-orm-graphql.esm.prod.js index fdb45c5e..7fb7eaed 100644 --- a/dist/vuex-orm-graphql.esm.prod.js +++ b/dist/vuex-orm-graphql.esm.prod.js @@ -14099,13 +14099,14 @@ class Transformer { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - static transformOutgoingData(model, data, read, action, whitelist, outgoingRecords, recursiveCall) { + static transformOutgoingData(model, data, read, action, mutationName, whitelist, outgoingRecords, recursiveCall) { const context = Context.getInstance(); const relations = model.getRelations(); const returnValue = {}; @@ -14127,7 +14128,7 @@ class Transformer { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { + this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, mutationName, whitelist)) { let relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14135,7 +14136,7 @@ class Transformer { if (arrayModel) { this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(v => { - return this.transformOutgoingData(arrayModel || model, v, read, action, undefined, outgoingRecords, true); + return this.transformOutgoingData(arrayModel || model, v, read, action, mutationName, undefined, outgoingRecords, true); }); } else { @@ -14149,7 +14150,7 @@ class Transformer { } this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); + returnValue[key] = this.transformOutgoingData(relatedModel, value, read, action, mutationName, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14233,10 +14234,11 @@ class Transformer { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, whitelist) { + static shouldIncludeOutgoingField(forFilter, fieldName, value, model, action, mutationName, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14249,8 +14251,9 @@ class Transformer { // Ignore empty fields if (value === null || value === undefined) return false; + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14273,9 +14276,11 @@ class Transformer { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - static inputTypeContainsField(model, fieldName, action) { + static inputTypeContainsField(model, fieldName, action, mutationName) { const context = Context.getInstance(); - const inputTypeName = context.adapter.getInputTypeName(model, action); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + const inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 const inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`); @@ -14691,7 +14696,7 @@ class DefaultAdapter { getFilterTypeName(model) { return `${upcaseFirstLetter(model.singularName)}Filter`; } - getInputTypeName(model, action) { + getInputTypeName(model, action, mutation) { return `${upcaseFirstLetter(model.singularName)}Input`; } getNameForDestroy(model) { @@ -15148,7 +15153,8 @@ class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action, field === null || field === void 0 ? void 0 : field.name) + "!"; //1 } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15415,8 +15421,9 @@ class Action { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args, model, data, action) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + static addRecordToArgs(args, model, data, action, mutationName) { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action, mutationName); return args; } /** @@ -15431,7 +15438,7 @@ class Action { const value = args[key]; if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false, action); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action, ''); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15525,7 +15532,7 @@ class Fetch extends Action { // Filter let filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, '', Object.keys(params.filter)); } const bypassCache = params && params.bypassCache; // When the filter contains an id, we query in singular mode @@ -15635,7 +15642,8 @@ class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); // Send mutation const newRecord = await Action.mutation(mutationName, args, dispatch, model, action); // Delete the old record if necessary @@ -15701,7 +15709,7 @@ class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return Action.mutation(mutationName, args, dispatch, model, action); } @@ -15758,7 +15766,7 @@ class Query extends Action { } const schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action, '') : {}; // Multiple? const multiple = Schema.returnsConnection(schema.getQuery(name)); // Build query diff --git a/dist/vuex-orm-graphql.global.js b/dist/vuex-orm-graphql.global.js index 1f623d32..085a3a0e 100644 --- a/dist/vuex-orm-graphql.global.js +++ b/dist/vuex-orm-graphql.global.js @@ -14120,13 +14120,14 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. * @param {boolean} recursiveCall Tells if it's a recursive call. * @returns {Data} */ - Transformer.transformOutgoingData = function (model, data, read, action, whitelist, outgoingRecords, recursiveCall) { + Transformer.transformOutgoingData = function (model, data, read, action, mutationName, whitelist, outgoingRecords, recursiveCall) { var _this = this; var context = Context.getInstance(); var relations = model.getRelations(); @@ -14149,7 +14150,7 @@ var VuexORMGraphQLPlugin = (function (exports) { // we want to include any relation, so we have to make sure it's false. In the recursive calls // it should be true when we transform the outgoing data for fetch (and false for the others) if (!isRecursion && - _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, whitelist)) { + _this.shouldIncludeOutgoingField(recursiveCall && read, key, value, model, action, mutationName, whitelist)) { var relatedModel = Model.getRelatedModel(relations.get(key)); if (value instanceof Array) { // Either this is a hasMany field or a .attr() field which contains an array. @@ -14157,7 +14158,7 @@ var VuexORMGraphQLPlugin = (function (exports) { if (arrayModel_1) { _this.addRecordForRecursionDetection(outgoingRecords, value[0]); returnValue[key] = value.map(function (v) { - return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, undefined, outgoingRecords, true); + return _this.transformOutgoingData(arrayModel_1 || model, v, read, action, mutationName, undefined, outgoingRecords, true); }); } else { @@ -14171,7 +14172,7 @@ var VuexORMGraphQLPlugin = (function (exports) { } _this.addRecordForRecursionDetection(outgoingRecords, value); // Value is a record, transform that too - returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, undefined, outgoingRecords, true); + returnValue[key] = _this.transformOutgoingData(relatedModel, value, read, action, mutationName, undefined, outgoingRecords, true); } else { // In any other case just let the value be what ever it is @@ -14258,10 +14259,11 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ - Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, whitelist) { + Transformer.shouldIncludeOutgoingField = function (forFilter, fieldName, value, model, action, mutationName, whitelist) { // Always add fields on the whitelist. if (whitelist && whitelist.includes(fieldName)) return true; @@ -14274,8 +14276,9 @@ var VuexORMGraphQLPlugin = (function (exports) { // Ignore empty fields if (value === null || value === undefined) return false; + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -14298,9 +14301,11 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - Transformer.inputTypeContainsField = function (model, fieldName, action) { + Transformer.inputTypeContainsField = function (model, fieldName, action, mutationName) { var context = Context.getInstance(); - var inputTypeName = context.adapter.getInputTypeName(model, action); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + var inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 var inputType = context.schema.getType(inputTypeName, false); if (inputType === null) throw new Error("Type " + inputType + " doesn't exist."); @@ -14753,7 +14758,7 @@ var VuexORMGraphQLPlugin = (function (exports) { DefaultAdapter.prototype.getFilterTypeName = function (model) { return upcaseFirstLetter(model.singularName) + "Filter"; }; - DefaultAdapter.prototype.getInputTypeName = function (model, action) { + DefaultAdapter.prototype.getInputTypeName = function (model, action, mutation) { return upcaseFirstLetter(model.singularName) + "Input"; }; DefaultAdapter.prototype.getNameForDestroy = function (model) { @@ -15128,7 +15133,8 @@ var VuexORMGraphQLPlugin = (function (exports) { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action, field === null || field === void 0 ? void 0 : field.name) + "!"; //1 } else if (value instanceof Array && field) { var arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -15434,8 +15440,9 @@ var VuexORMGraphQLPlugin = (function (exports) { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - Action.addRecordToArgs = function (args, model, data, action) { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + Action.addRecordToArgs = function (args, model, data, action, mutationName) { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action, mutationName); return args; }; /** @@ -15450,7 +15457,7 @@ var VuexORMGraphQLPlugin = (function (exports) { var value = args[key]; if (value instanceof context.components.Model) { var model = context.getModel(singularize(value.$self().entity)); - var transformedValue = Transformer.transformOutgoingData(model, value, false, action); + var transformedValue = Transformer.transformOutgoingData(model, value, false, action, ''); context.logger.log("A", key, "model was found within the variables and will be transformed from", value, "to", transformedValue); args[key] = transformedValue; } @@ -15591,7 +15598,7 @@ var VuexORMGraphQLPlugin = (function (exports) { _b.sent(); filter = {}; if (params && params.filter) { - filter = Transformer.transformOutgoingData(model, params.filter, true, action, Object.keys(params.filter)); + filter = Transformer.transformOutgoingData(model, params.filter, true, action, '', Object.keys(params.filter)); } bypassCache = params && params.bypassCache; multiple = !filter["id"]; @@ -15751,7 +15758,8 @@ var VuexORMGraphQLPlugin = (function (exports) { // Arguments _c.sent(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); return [4 /*yield*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 5: newRecord = _c.sent(); @@ -15845,7 +15853,7 @@ var VuexORMGraphQLPlugin = (function (exports) { // Arguments _c.sent(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return [2 /*return*/, Action.mutation(mutationName, args, dispatch, model, action)]; case 2: @@ -15927,7 +15935,7 @@ var VuexORMGraphQLPlugin = (function (exports) { case 1: schema = _c.sent(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter, true, action) : {}; + filter = filter ? Transformer.transformOutgoingData(model, filter, true, action, '') : {}; multiple = Schema.returnsConnection(schema.getQuery(name)); query = QueryBuilder.buildQuery("query", model, action, name, filter, multiple, false); return [4 /*yield*/, context.apollo.request(model, query, filter, false, bypassCache)]; diff --git a/dist/vuex-orm-graphql.global.prod.js b/dist/vuex-orm-graphql.global.prod.js index 708d0904..c7b03aab 100644 --- a/dist/vuex-orm-graphql.global.prod.js +++ b/dist/vuex-orm-graphql.global.prod.js @@ -12,4 +12,4 @@ var VuexORMGraphQLPlugin=function(e){"use strict"; See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. - ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+W(e.values,", ")+"]"},ObjectValue:function(e){return"{"+W(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",W(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return W(["schema",W(t," "),J(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return W(["scalar",e.name,W(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+": "+r+H(" ",W(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return W([t+": "+n,H("= ",r),W(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["interface",t,W(n," "),J(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return W(["union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return W(["enum",t,W(n," "),J(r)]," ")})),EnumValueDefinition:Y((function(e){return W([e.name,W(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["input",t,W(n," "),J(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return W(["extend schema",W(t," "),J(n)]," ")},ScalarTypeExtension:function(e){return W(["extend scalar",e.name,W(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["extend type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend interface",t,W(n," "),J(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return W(["extend union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return W(["extend enum",t,W(n," "),J(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend input",t,W(n," "),J(r)]," ")}};function Y(e){return function(t){return W([t.description,e(t)],"\n")}}function W(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function J(e){return e&&0!==e.length?"{\n"+X(W(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=_r.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=_r.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",me(e)).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=_r.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof _r.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),Ee=Object.setPrototypeOf,we=void 0===Ee?function(e,t){return e.__proto__=t,e}:Ee,_e=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",we(r,t.prototype),r}return n(t,e),t}(Error);function Oe(e,t){if(!e)throw new _e(t)}function ke(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=ke("warn"),e.error=ke("error")}(Oe||(Oe={}));var Ne={env:{}};if("object"==typeof process)Ne=process;else try{Function("stub","process = stub")(Ne)}catch(e){}var Se=Object.prototype,Te=Se.toString,Ie=Se.hasOwnProperty,xe=new Map;function De(e,t){try{return function e(t,n){if(t===n)return!0;var r=Te.call(t),i=Te.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(Ae(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Ue(e){return e&&Be(["client"],e)&&Be(["export"],e)}function Ge(e){var t=e.name.value;return"skip"===t||"include"===t}function ze(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new _e(5):new _e("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?Oe(1===i.length,6):Oe(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function Ke(e){for(var t=[],n=1;n1){var r=[];t=wt(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var $t,Bt=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Lt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}($t||($t={}));var Ut=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=We(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Qt.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Lt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new Bt({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:Pt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Qt.loading:Qt.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&De(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new _e(3):new _e("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),De(this.variables,e)||(this.variables=r(r({},this.variables),e)),De(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),$t.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Oe(e.updateQuery,4):Oe(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,$t.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Oe.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&De(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=ht((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){Kt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:lt(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Gt)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(Kt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Qt.error,loading:!1})),zt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!De(a,i)?e.refetch():zt(e.observers,"next",n)})):zt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Vt);function Gt(e){"production"===process.env.NODE_ENV||Oe.error("Unhandled error",e.message,e.stack)}function zt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function Kt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Oe("cache-first"!==t&&"cache-only"!==t,5):Oe("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Wt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Oe(!t||t.document===e.document||De(t.document,e.document),19):Oe(!t||t.document===e.document||De(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Qt.loading&&(De(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Qt.setVariables:e.isPoll?Qt.poll:e.isRefetch?Qt.refetch:Qt.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Qt.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Lt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Qt.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Qt.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Qt.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Qt.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Qt.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=mt(t.resolvers,e)})):this.resolvers=mt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(Be(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Oe.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ye(e);var t=ot([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qe(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Oe(!1,6):Oe(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:st(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=Xe(e),c=He(e),l=Ze(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return $e(e,s)?Qe(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[Ce(e)]=t,n))}))]:(qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?Oe(i,7):Oe(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return gt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=Ce(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,je(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Ht(e){var t=new Set,n=null;return new Vt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Xt=Object.prototype.hasOwnProperty,Zt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Yt,this.queryStore=new Wt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(ut?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(8):new _e("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?Oe(t,9):Oe(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Oe(!v||"no-cache"===v,10):Oe(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Xt.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){dt(r)&&"none"===d?h=new Bt({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new Bt({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Lt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&dt(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,Be(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===$t.poll,isRefetch:n===$t.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new Bt({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||Oe.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Oe.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=Pt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Lt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new Bt({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new Bt({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),ot([at],Ye(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Ue(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:et(We(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Oe("standby"!==e.fetchPolicy,11):Oe("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Ut({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Oe(e.query,12):Oe(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Oe("Document"===e.query.kind,13):Oe("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Oe(!e.returnPartialData,14):Oe(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Oe(!e.pollInterval,15):Oe(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(16):new _e("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||Oe.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),dt(i))throw new Bt({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Vt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Oe(n,17):Oe(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Ht(Ct(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Ht(Ct(c,l))}else o=Vt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Vt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Lt(e.errors))return l(new Bt({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Qt.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Qt.ready&&t.networkStatus!==Qt.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?Oe(o,18):Oe(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,$t.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),en=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!dt(e);i&&dt(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){dt(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!dt(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=ht((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&ht((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),tn=!1,nn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=jt.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new _e(1):new _e("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new en(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),tn||"production"===process.env.NODE_ENV||(tn=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Zt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Oe("cache-and-network"!==e.fetchPolicy,2):Oe("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Ct(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Oe.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function rn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(e)}]}}function on(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return on(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:on(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var an={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},sn=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:ze(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:ze(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:an})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(t)}]}),data:s})}else this.writeQuery({query:rn(i),data:i})},e}(),un=null,cn={},ln=1,fn=Array,pn=fn["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",ln++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=un;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===cn)break;return e!==un&&(un.slots[this.id]=t),!0}return un&&(un.slots[this.id]=cn),!1},e.prototype.getValue=function(){if(this.hasValue())return un.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=un;un={parent:a,slots:o};try{return t.apply(r,n)}finally{un=a}},e.bind=function(e){var t=un;return function(){var n=un;try{return un=t,e.apply(this,arguments)}finally{un=n}}},e.noContext=function(e,t,n){if(!un)return e.apply(n,t);var r=un;try{return un=null,e.apply(n,t)}finally{un=r}},e}();try{Object.defineProperty(fn,"@wry/context:Slot",{value:fn["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();pn.bind,pn.noContext;function hn(){}var dn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=hn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),vn=new pn,yn=[],mn=[];function gn(e,t){if(!e)throw new Error(t||"assertion failure")}function bn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var En=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(gn(!this.recomputing,"already recomputing"),function(e){var t=vn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),_n(e)?Nn(t,e):Sn(t,e),t}(this)||!In(this))return _n(this)?function(e){var t=xn(e);vn.withValue(e,wn,[e]),function(e){if("function"==typeof e.subscribe)try{An(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,_n(e))return;kn(e)}(e);return t.forEach(In),bn(e.value)}(this):bn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,On(this),An(this))},e.prototype.dispose=function(){var e=this;xn(this).forEach(In),An(this),this.parents.forEach((function(t){t.setDirty(),Dn(t,e)}))},e.count=0,e}();function wn(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function _n(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e){e.parents.forEach((function(t){return Sn(t,e)}))}function Nn(e,t){if(gn(e.childValues.has(t)),gn(_n(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=mn.pop()||new Set;e.dirtyChildren.add(t),On(e)}function Sn(e,t){gn(e.childValues.has(t)),gn(!_n(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Tn(e,t),_n(e)||kn(e)}function Tn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(mn.length<100&&mn.push(n),e.dirtyChildren=null))}function In(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function xn(e){var t=yn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){Dn(e,r),t.push(r)}))),gn(null===e.dirtyChildren),t}function Dn(e,t){t.parents.delete(e),e.childValues.delete(t),Tn(e,t)}function An(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var Rn=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new _e(8):new _e("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&De(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Gn:o,s=Xe(t),u={query:t,fragmentMap:Ze(He(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if($e(e,u))if(Qe(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[Ce(e)]=c,n))}else{var d=void 0;if(qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new _e(9):new _e("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=gt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Fe(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Ve({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,je(n,i),o,{resultKey:Ce(n),directives:Le(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Un(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&vt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Hn={fragmentMatcher:new Pn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Xn=Object.prototype.hasOwnProperty,Zn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Xn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(zn),er=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new Rn(ut),n.silenceBroadcast=!1,n.config=r(r({},Hn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||Oe.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||Oe.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Ln:new zn,n.optimisticData=n.data,n.storeWriter=new Yn,n.storeReader=new Bn({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=Cn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Ln?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new _e(1):new _e("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Zn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Zn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ye(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Qe(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Qe(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[nt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(sn),tr={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},nr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},rr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new _e(2):new _e("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},ir=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&nr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||nr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var or,ar,sr=function(e){function t(t){return e.call(this,ir(t).request)||this}return n(t,e),t}(jt);(or=e.ConnectionMode||(e.ConnectionMode={}))[or.AUTO=0]="AUTO",or[or.PLAIN=1]="PLAIN",or[or.NODES=2]="NODES",or[or.EDGES=3]="EDGES",or[or.ITEMS=4]="ITEMS",(ar=e.ArgumentMode||(e.ArgumentMode={}))[ar.TYPE=0]="TYPE",ar[ar.LIST=1]="LIST";var ur,cr=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o,a){var s=this,u=_r.getInstance(),c=e.getRelations(),l={};return void 0===o&&(o=new Map),void 0===a&&(a=!1),Object.keys(t).forEach((function(f){var p=t[f],h=e.getRelations().has(f);if(!(p instanceof Array?h&&s.isRecursion(o,p[0]):h&&s.isRecursion(o,p))&&s.shouldIncludeOutgoingField(a&&n,f,p,e,r,i)){var d=be.getRelatedModel(c.get(f));if(p instanceof Array){var v=u.getModel(se(f),!0);v?(s.addRecordForRecursionDetection(o,p[0]),l[f]=p.map((function(t){return s.transformOutgoingData(v||e,t,n,r,void 0,o,!0)}))):l[f]=p}else"object"==typeof p&&void 0!==p.$id?(d||(d=u.getModel(p.$self().entity)),s.addRecordForRecursionDetection(o,p),l[f]=s.transformOutgoingData(d,p,n,r,void 0,o,!0)):l[f]=p}})),l},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=_r.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else if(t[u].items&&s.connectionMode===e.ConnectionMode.ITEMS)a[ae(u)]=o.transformIncomingData(t[u].items,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else be.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i,o){if(o&&o.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(!this.inputTypeContainsField(r,t,i))return!1;if(r.getRelations().has(t)){if(e)return!1;var a=r.getRelations().get(t),s=be.getRelatedModel(a);return!(!s||!r.shouldEagerSaveRelation(t,a,s))}return!0},t.inputTypeContainsField=function(e,t,n){var r=_r.getInstance(),i=r.adapter.getInputTypeName(e,n),o=r.schema.getType(i,!1);if(null===o)throw new Error("Type "+o+" doesn't exist.");return void 0!==o.inputFields.find((function(e){return e.name===t}))},t.addRecordForRecursionDetection=function(e,t){var n=_r.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return _r.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=_r.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),lr=((ur=V)&&ur.default||ur).parse;function fr(e){return e.replace(/[\s,]+/g," ").trim()}var pr={},hr={};var dr=!0;var vr=!1;function yr(e){var t=fr(e);if(pr[t])return pr[t];var n=lr(e,{experimentalFragmentVariables:vr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(s.singularName);if(e.shouldEagerLoadRelation(a,o,s)&&!c){var l=t.slice(0);l.push(s.singularName),i.push(r.buildField(s,n,be.isConnection(o),void 0,l,a,!1))}})),i.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(_r.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),kr=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],_r.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),Nr=function(){function e(){}return e.mutation=function(e,t,n,r,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=_r.getInstance()).loadSchema()]:[3,5];case 1:return s=o.sent(),u=Er.returnsConnection(s.getMutation(e)),c=Or.buildQuery("mutation",r,a,e,t,u),[4,i.apollo.request(r,c,t,!0)];case 2:return l=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((l=l[Object.keys(l)[0]]).id=me(l.id),[4,kr.insertData((d={},d[r.pluralName]=l,d),n)]);case 3:return f=o.sent(),p=f[r.pluralName],(h=p[p.length-1])?[2,h]:(_r.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",f,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return _r.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n,r){return e[t.singularName]=cr.transformOutgoingData(t,n,!1,r),e},e.transformArgs=function(e,t){var n=_r.getInstance();return Object.keys(e).forEach((function(r){var i=e[r];if(i instanceof n.components.Model){var o=n.getModel(se(i.$self().entity)),a=cr.transformOutgoingData(o,i,!1,t);n.logger.log("A",r,"model was found within the variables and will be transformed from",i,"to",a),e[r]=a}})),e},e}(),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.destroy=t.call.bind(t),n.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:me(this.$id)})]}))}))},n.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForDestroy(e),i="destroy",(u=e.$mockHook("destroy",{id:a}))?[4,kr.insertData(u,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,Nr.mutation(t,s,r,e,i)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(Nr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model;e.components.Actions.fetch=t.call.bind(t),n.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),i=this.getModelFromState(n),a="fetch",(s=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,kr.insertData(s,r)]:[4,e.loadSchema()];case 1:return o.sent(),u={},t&&t.filter&&(u=cr.transformOutgoingData(i,t.filter,!0,a,Object.keys(t.filter))),c=t&&t.bypassCache,l=!u.id,f=e.adapter.getNameForFetch(i,l),p=Or.buildQuery("query",i,a,f,u,l,l),[4,e.apollo.request(i,p,u,!1,c)];case 2:return h=o.sent(),[2,kr.insertData(h,r)]}}))}))},t}(Nr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.mutate=t.call.bind(t),n.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},r.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return s?(e=_r.getInstance(),t=this.getModelFromState(n),i="mutate",(u=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,kr.insertData(u,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a,i),[2,Nr.mutation(s,a,r,t,i)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(Nr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.persist=t.call.bind(t),n.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l,f;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),u="persist",(c=e.$mockHook("persist",{id:me(a),args:s||{}}))?[4,kr.insertData(c,r)]:[3,3]):[3,7];case 1:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 2:return o.sent(),[2,l];case 3:return[4,_r.getInstance().loadSchema()];case 4:return o.sent(),s=this.prepareArgs(s),this.addRecordToArgs(s,e,i,u),[4,Nr.mutation(t,s,r,e,u)];case 5:return f=o.sent(),[4,this.deleteObsoleteRecord(e,f,i)];case 6:return o.sent(),[2,f];case 7:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(_r.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(Nr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.push=t.call.bind(t),n.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPush(e),i="push",(u=e.$mockHook("push",{data:a,args:s||{}}))?[2,kr.insertData(u,r)]:[4,_r.getInstance().loadSchema()]):[3,2];case 1:return o.sent(),s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a,i),[2,Nr.mutation(t,s,r,e,i)];case 2:throw new Error("The persist action requires the 'data' to be set")}}))}))},t}(Nr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.query=t.call.bind(t),n.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},r.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return a?(e=_r.getInstance(),t=this.getModelFromState(n),i="query",(c=t.$mockHook("query",{name:a,filter:s||{}}))?[2,kr.insertData(c,r)]:[4,e.loadSchema()]):[3,3];case 1:return l=o.sent(),s=s?cr.transformOutgoingData(t,s,!0,i):{},f=Er.returnsConnection(l.getQuery(a)),p=Or.buildQuery("query",t,i,a,s,f,!1),[4,e.apollo.request(t,p,s,!1,u)];case 2:return h=o.sent(),[2,kr.insertData(h,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(Nr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleQuery=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(Nr),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleMutation=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(Nr),Fr=function(){function e(t,n){_r.setup(t,n),e.setupActions()}return e.prototype.getContext=function(){return _r.getInstance()},e.setupActions=function(){Tr.setup(),xr.setup(),Dr.setup(),Sr.setup(),Ir.setup(),Ar.setup(),Rr.setup(),Mr.setup()},e}(),jr=function(){function e(){}return e.install=function(t,n){return e.instance=new Fr(t,n),e.instance},e}(),Cr=null;var Qr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?Cr.addGlobalMock(this):Cr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=wr,e.Mock=Qr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!Cr)throw new Error("Please call setupTestUtils() before!");return[4,Cr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=jr,e.mock=function(e,t){if(!Cr)throw new Error("Please call setupTestUtils() before!");return new Qr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");Cr=e.instance.getContext()},e}({}); + ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2)return"[Array]";for(var n=Math.min(10,e.length),r=e.length-n,i=[],o=0;o1&&i.push("... ".concat(r," more items"));return"["+i.join(", ")+"]"}(e,n);return function(e,t){var n=Object.keys(e);if(0===n.length)return"{}";if(t.length>2)return"["+function(e){var t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){var n=e.constructor.name;if("string"==typeof n&&""!==n)return n}return t}(e)+"]";return"{ "+n.map((function(n){return n+": "+l(e[n],t)})).join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}function f(e,t){if(!Boolean(e))throw new Error(t)}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.prototype.toString;e.prototype.toJSON=t,e.prototype.inspect=t,s&&(e.prototype[s]=t)}function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n,r=/\r\n|[\n\r]/g,i=1,o=t+1;(n=r.exec(e.body))&&n.index120){for(var p=Math.floor(u/80),h=u%80,d=[],v=0;v0||f(0,"line in locationOffset is 1-indexed and must be positive"),this.locationOffset.column>0||f(0,"column in locationOffset is 1-indexed and must be positive")};function k(e){var t=e.split(/\r\n|[\n\r]/g),n=function(e){for(var t=null,n=1;n0&&S(t[0]);)t.shift();for(;t.length>0&&S(t[t.length-1]);)t.pop();return t.join("\n")}function N(e){for(var t=0;t",EOF:"",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function I(){return this.lastToken=this.token,this.token=this.lookahead()}function x(){var e=this.token;if(e.kind!==T.EOF)do{e=e.next||(e.next=R(this,e))}while(e.kind===T.COMMENT);return e}function D(e,t,n,r,i,o,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=o,this.next=null}function A(e){return isNaN(e)?T.EOF:e<127?JSON.stringify(String.fromCharCode(e)):'"\\u'.concat(("00"+e.toString(16).toUpperCase()).slice(-4),'"')}function R(e,t){var n=e.source,r=n.body,i=r.length,o=function(e,t,n){var r=e.length,i=t;for(;i=i)return new D(T.EOF,i,i,a,s,t);var u=r.charCodeAt(o);switch(u){case 33:return new D(T.BANG,o,o+1,a,s,t);case 35:return function(e,t,n,r,i){var o,a=e.body,s=t;do{o=a.charCodeAt(++s)}while(!isNaN(o)&&(o>31||9===o));return new D(T.COMMENT,t,s,n,r,i,a.slice(t+1,s))}(n,o,a,s,t);case 36:return new D(T.DOLLAR,o,o+1,a,s,t);case 38:return new D(T.AMP,o,o+1,a,s,t);case 40:return new D(T.PAREN_L,o,o+1,a,s,t);case 41:return new D(T.PAREN_R,o,o+1,a,s,t);case 46:if(46===r.charCodeAt(o+1)&&46===r.charCodeAt(o+2))return new D(T.SPREAD,o,o+3,a,s,t);break;case 58:return new D(T.COLON,o,o+1,a,s,t);case 61:return new D(T.EQUALS,o,o+1,a,s,t);case 64:return new D(T.AT,o,o+1,a,s,t);case 91:return new D(T.BRACKET_L,o,o+1,a,s,t);case 93:return new D(T.BRACKET_R,o,o+1,a,s,t);case 123:return new D(T.BRACE_L,o,o+1,a,s,t);case 124:return new D(T.PIPE,o,o+1,a,s,t);case 125:return new D(T.BRACE_R,o,o+1,a,s,t);case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 95:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:case 119:case 120:case 121:case 122:return function(e,t,n,r,i){var o=e.body,a=o.length,s=t+1,u=0;for(;s!==a&&!isNaN(u=o.charCodeAt(s))&&(95===u||u>=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122);)++s;return new D(T.NAME,t,s,n,r,i,o.slice(t,s))}(n,o,a,s,t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return function(e,t,n,r,i,o){var a=e.body,s=n,u=t,c=!1;45===s&&(s=a.charCodeAt(++u));if(48===s){if((s=a.charCodeAt(++u))>=48&&s<=57)throw E(e,u,"Invalid number, unexpected digit after 0: ".concat(A(s),"."))}else u=M(e,u,s),s=a.charCodeAt(u);46===s&&(c=!0,s=a.charCodeAt(++u),u=M(e,u,s),s=a.charCodeAt(u));69!==s&&101!==s||(c=!0,43!==(s=a.charCodeAt(++u))&&45!==s||(s=a.charCodeAt(++u)),u=M(e,u,s),s=a.charCodeAt(u));if(46===s||69===s||101===s)throw E(e,u,"Invalid number, expected digit but got: ".concat(A(s),"."));return new D(c?T.FLOAT:T.INT,t,u,r,i,o,a.slice(t,u))}(n,o,u,a,s,t);case 34:return 34===r.charCodeAt(o+1)&&34===r.charCodeAt(o+2)?function(e,t,n,r,i,o){var a=e.body,s=t+3,u=s,c=0,l="";for(;s=48&&o<=57){do{o=r.charCodeAt(++i)}while(o>=48&&o<=57);return i}throw E(e,i,"Invalid number, expected digit but got: ".concat(A(o),"."))}function F(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}p(D,(function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}));var j=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function C(e,t){return new Q(e,t).parseDocument()}var Q=function(){function e(e,t){var n="string"==typeof e?new O(e):e;n instanceof O||f(0,"Must provide Source. Received: ".concat(c(n))),this._lexer=function(e,t){var n=new D(T.SOF,0,0,0,0,null);return{source:e,options:t,lastToken:n,token:n,line:1,lineStart:0,advance:I,lookahead:x}}(n),this._options=t||{}}var t=e.prototype;return t.parseName=function(){var e=this.expectToken(T.NAME);return{kind:w.NAME,value:e.value,loc:this.loc(e)}},t.parseDocument=function(){var e=this._lexer.token;return{kind:w.DOCUMENT,definitions:this.many(T.SOF,this.parseDefinition,T.EOF),loc:this.loc(e)}},t.parseDefinition=function(){if(this.peek(T.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek(T.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},t.parseOperationDefinition=function(){var e=this._lexer.token;if(this.peek(T.BRACE_L))return{kind:w.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(e)};var t,n=this.parseOperationType();return this.peek(T.NAME)&&(t=this.parseName()),{kind:w.OPERATION_DEFINITION,operation:n,name:t,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseOperationType=function(){var e=this.expectToken(T.NAME);switch(e.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(e)},t.parseVariableDefinitions=function(){return this.optionalMany(T.PAREN_L,this.parseVariableDefinition,T.PAREN_R)},t.parseVariableDefinition=function(){var e=this._lexer.token;return{kind:w.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(e)}},t.parseVariable=function(){var e=this._lexer.token;return this.expectToken(T.DOLLAR),{kind:w.VARIABLE,name:this.parseName(),loc:this.loc(e)}},t.parseSelectionSet=function(){var e=this._lexer.token;return{kind:w.SELECTION_SET,selections:this.many(T.BRACE_L,this.parseSelection,T.BRACE_R),loc:this.loc(e)}},t.parseSelection=function(){return this.peek(T.SPREAD)?this.parseFragment():this.parseField()},t.parseField=function(){var e,t,n=this._lexer.token,r=this.parseName();return this.expectOptionalToken(T.COLON)?(e=r,t=this.parseName()):t=r,{kind:w.FIELD,alias:e,name:t,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(n)}},t.parseArguments=function(e){var t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(T.PAREN_L,t,T.PAREN_R)},t.parseArgument=function(){var e=this._lexer.token,t=this.parseName();return this.expectToken(T.COLON),{kind:w.ARGUMENT,name:t,value:this.parseValueLiteral(!1),loc:this.loc(e)}},t.parseConstArgument=function(){var e=this._lexer.token;return{kind:w.ARGUMENT,name:this.parseName(),value:(this.expectToken(T.COLON),this.parseValueLiteral(!0)),loc:this.loc(e)}},t.parseFragment=function(){var e=this._lexer.token;this.expectToken(T.SPREAD);var t=this.expectOptionalKeyword("on");return!t&&this.peek(T.NAME)?{kind:w.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(e)}:{kind:w.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentDefinition=function(){var e=this._lexer.token;return this.expectKeyword("fragment"),this._options.experimentalFragmentVariables?{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}:{kind:w.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(e)}},t.parseFragmentName=function(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()},t.parseValueLiteral=function(e){var t=this._lexer.token;switch(t.kind){case T.BRACKET_L:return this.parseList(e);case T.BRACE_L:return this.parseObject(e);case T.INT:return this._lexer.advance(),{kind:w.INT,value:t.value,loc:this.loc(t)};case T.FLOAT:return this._lexer.advance(),{kind:w.FLOAT,value:t.value,loc:this.loc(t)};case T.STRING:case T.BLOCK_STRING:return this.parseStringLiteral();case T.NAME:return"true"===t.value||"false"===t.value?(this._lexer.advance(),{kind:w.BOOLEAN,value:"true"===t.value,loc:this.loc(t)}):"null"===t.value?(this._lexer.advance(),{kind:w.NULL,loc:this.loc(t)}):(this._lexer.advance(),{kind:w.ENUM,value:t.value,loc:this.loc(t)});case T.DOLLAR:if(!e)return this.parseVariable()}throw this.unexpected()},t.parseStringLiteral=function(){var e=this._lexer.token;return this._lexer.advance(),{kind:w.STRING,value:e.value,block:e.kind===T.BLOCK_STRING,loc:this.loc(e)}},t.parseList=function(e){var t=this,n=this._lexer.token;return{kind:w.LIST,values:this.any(T.BRACKET_L,(function(){return t.parseValueLiteral(e)}),T.BRACKET_R),loc:this.loc(n)}},t.parseObject=function(e){var t=this,n=this._lexer.token;return{kind:w.OBJECT,fields:this.any(T.BRACE_L,(function(){return t.parseObjectField(e)}),T.BRACE_R),loc:this.loc(n)}},t.parseObjectField=function(e){var t=this._lexer.token,n=this.parseName();return this.expectToken(T.COLON),{kind:w.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e),loc:this.loc(t)}},t.parseDirectives=function(e){for(var t=[];this.peek(T.AT);)t.push(this.parseDirective(e));return t},t.parseDirective=function(e){var t=this._lexer.token;return this.expectToken(T.AT),{kind:w.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e),loc:this.loc(t)}},t.parseTypeReference=function(){var e,t=this._lexer.token;return this.expectOptionalToken(T.BRACKET_L)?(e=this.parseTypeReference(),this.expectToken(T.BRACKET_R),e={kind:w.LIST_TYPE,type:e,loc:this.loc(t)}):e=this.parseNamedType(),this.expectOptionalToken(T.BANG)?{kind:w.NON_NULL_TYPE,type:e,loc:this.loc(t)}:e},t.parseNamedType=function(){var e=this._lexer.token;return{kind:w.NAMED_TYPE,name:this.parseName(),loc:this.loc(e)}},t.parseTypeSystemDefinition=function(){var e=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}throw this.unexpected(e)},t.peekDescription=function(){return this.peek(T.STRING)||this.peek(T.BLOCK_STRING)},t.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},t.parseSchemaDefinition=function(){var e=this._lexer.token;this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.many(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);return{kind:w.SCHEMA_DEFINITION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseOperationTypeDefinition=function(){var e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.COLON);var n=this.parseNamedType();return{kind:w.OPERATION_TYPE_DEFINITION,operation:t,type:n,loc:this.loc(e)}},t.parseScalarTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");var n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");var n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseDirectives(!0),o=this.parseFieldsDefinition();return{kind:w.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:o,loc:this.loc(e)}},t.parseImplementsInterfaces=function(){var e=[];if(this.expectOptionalKeyword("implements")){this.expectOptionalToken(T.AMP);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.AMP)||this._options.allowLegacySDLImplementsInterfaces&&this.peek(T.NAME))}return e},t.parseFieldsDefinition=function(){return this._options.allowLegacySDLEmptyFields&&this.peek(T.BRACE_L)&&this._lexer.lookahead().kind===T.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(T.BRACE_L,this.parseFieldDefinition,T.BRACE_R)},t.parseFieldDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(T.COLON);var i=this.parseTypeReference(),o=this.parseDirectives(!0);return{kind:w.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:o,loc:this.loc(e)}},t.parseArgumentDefs=function(){return this.optionalMany(T.PAREN_L,this.parseInputValueDef,T.PAREN_R)},t.parseInputValueDef=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.COLON);var r,i=this.parseTypeReference();this.expectOptionalToken(T.EQUALS)&&(r=this.parseValueLiteral(!0));var o=this.parseDirectives(!0);return{kind:w.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:o,loc:this.loc(e)}},t.parseInterfaceTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();return{kind:w.INTERFACE_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseUnionTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseUnionMemberTypes();return{kind:w.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i,loc:this.loc(e)}},t.parseUnionMemberTypes=function(){var e=[];if(this.expectOptionalToken(T.EQUALS)){this.expectOptionalToken(T.PIPE);do{e.push(this.parseNamedType())}while(this.expectOptionalToken(T.PIPE))}return e},t.parseEnumTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseEnumValuesDefinition();return{kind:w.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i,loc:this.loc(e)}},t.parseEnumValuesDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseEnumValueDefinition,T.BRACE_R)},t.parseEnumValueDefinition=function(){var e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseDirectives(!0);return{kind:w.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r,loc:this.loc(e)}},t.parseInputObjectTypeDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");var n=this.parseName(),r=this.parseDirectives(!0),i=this.parseInputFieldsDefinition();return{kind:w.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInputFieldsDefinition=function(){return this.optionalMany(T.BRACE_L,this.parseInputValueDef,T.BRACE_R)},t.parseTypeSystemExtension=function(){var e=this._lexer.lookahead();if(e.kind===T.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)},t.parseSchemaExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var t=this.parseDirectives(!0),n=this.optionalMany(T.BRACE_L,this.parseOperationTypeDefinition,T.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return{kind:w.SCHEMA_EXTENSION,directives:t,operationTypes:n,loc:this.loc(e)}},t.parseScalarTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var t=this.parseName(),n=this.parseDirectives(!0);if(0===n.length)throw this.unexpected();return{kind:w.SCALAR_TYPE_EXTENSION,name:t,directives:n,loc:this.loc(e)}},t.parseObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseDirectives(!0),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return{kind:w.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i,loc:this.loc(e)}},t.parseInterfaceTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INTERFACE_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseUnionTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.UNION_TYPE_EXTENSION,name:t,directives:n,types:r,loc:this.loc(e)}},t.parseEnumTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r,loc:this.loc(e)}},t.parseInputObjectTypeExtension=function(){var e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var t=this.parseName(),n=this.parseDirectives(!0),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return{kind:w.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r,loc:this.loc(e)}},t.parseDirectiveDefinition=function(){var e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.AT);var n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var o=this.parseDirectiveLocations();return{kind:w.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:o,loc:this.loc(e)}},t.parseDirectiveLocations=function(){this.expectOptionalToken(T.PIPE);var e=[];do{e.push(this.parseDirectiveLocation())}while(this.expectOptionalToken(T.PIPE));return e},t.parseDirectiveLocation=function(){var e=this._lexer.token,t=this.parseName();if(void 0!==j[t.value])return t;throw this.unexpected(e)},t.loc=function(e){if(!this._options.noLocation)return new q(e,this._lexer.lastToken,this._lexer.source)},t.peek=function(e){return this._lexer.token.kind===e},t.expectToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t;throw E(this._lexer.source,t.start,"Expected ".concat(e,", found ").concat(P(t)))},t.expectOptionalToken=function(e){var t=this._lexer.token;if(t.kind===e)return this._lexer.advance(),t},t.expectKeyword=function(e){var t=this._lexer.token;if(t.kind!==T.NAME||t.value!==e)throw E(this._lexer.source,t.start,'Expected "'.concat(e,'", found ').concat(P(t)));this._lexer.advance()},t.expectOptionalKeyword=function(e){var t=this._lexer.token;return t.kind===T.NAME&&t.value===e&&(this._lexer.advance(),!0)},t.unexpected=function(e){var t=e||this._lexer.token;return E(this._lexer.source,t.start,"Unexpected ".concat(P(t)))},t.any=function(e,t,n){this.expectToken(e);for(var r=[];!this.expectOptionalToken(n);)r.push(t.call(this));return r},t.optionalMany=function(e,t,n){if(this.expectOptionalToken(e)){var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}return[]},t.many=function(e,t,n){this.expectToken(e);var r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r},e}();function q(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}function P(e){var t=e.value;return t?"".concat(e.kind,' "').concat(t,'"'):e.kind}p(q,(function(){return{start:this.start,end:this.end}}));var V=Object.freeze({__proto__:null,parse:C,parseValue:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseValueLiteral(!1);return n.expectToken(T.EOF),r},parseType:function(e,t){var n=new Q(e,t);n.expectToken(T.SOF);var r=n.parseTypeReference();return n.expectToken(T.EOF),r}}),L={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},$=Object.freeze({});function B(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:L,r=void 0,i=Array.isArray(e),o=[e],a=-1,s=[],u=void 0,l=void 0,f=void 0,p=[],h=[],d=e;do{var v=++a===o.length,y=v&&0!==s.length;if(v){if(l=0===h.length?void 0:p[p.length-1],u=f,f=h.pop(),y){if(i)u=u.slice();else{for(var m={},g=0,b=Object.keys(u);g1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=-1===e.indexOf("\n"),i=" "===e[0]||"\t"===e[0],o='"'===e[e.length-1],a=!r||o||n,s="";return!a||r&&i||(s+="\n"+t),s+=t?e.replace(/\n/g,"\n"+t):e,a&&(s+="\n"),'"""'+s.replace(/"""/g,'\\"""')+'"""'}(n,"description"===t?"":" "):JSON.stringify(n)},BooleanValue:function(e){return e.value?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){return e.value},ListValue:function(e){return"["+W(e.values,", ")+"]"},ObjectValue:function(e){return"{"+W(e.fields,", ")+"}"},ObjectField:function(e){return e.name+": "+e.value},Directive:function(e){return"@"+e.name+H("(",W(e.arguments,", "),")")},NamedType:function(e){return e.name},ListType:function(e){return"["+e.type+"]"},NonNullType:function(e){return e.type+"!"},SchemaDefinition:function(e){var t=e.directives,n=e.operationTypes;return W(["schema",W(t," "),J(n)]," ")},OperationTypeDefinition:function(e){return e.operation+": "+e.type},ScalarTypeDefinition:Y((function(e){return W(["scalar",e.name,W(e.directives," ")]," ")})),ObjectTypeDefinition:Y((function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")})),FieldDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.type,i=e.directives;return t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+": "+r+H(" ",W(i," "))})),InputValueDefinition:Y((function(e){var t=e.name,n=e.type,r=e.defaultValue,i=e.directives;return W([t+": "+n,H("= ",r),W(i," ")]," ")})),InterfaceTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["interface",t,W(n," "),J(r)]," ")})),UnionTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.types;return W(["union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")})),EnumTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.values;return W(["enum",t,W(n," "),J(r)]," ")})),EnumValueDefinition:Y((function(e){return W([e.name,W(e.directives," ")]," ")})),InputObjectTypeDefinition:Y((function(e){var t=e.name,n=e.directives,r=e.fields;return W(["input",t,W(n," "),J(r)]," ")})),DirectiveDefinition:Y((function(e){var t=e.name,n=e.arguments,r=e.repeatable,i=e.locations;return"directive @"+t+(ee(n)?H("(\n",X(W(n,"\n")),"\n)"):H("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")})),SchemaExtension:function(e){var t=e.directives,n=e.operationTypes;return W(["extend schema",W(t," "),J(n)]," ")},ScalarTypeExtension:function(e){return W(["extend scalar",e.name,W(e.directives," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,n=e.interfaces,r=e.directives,i=e.fields;return W(["extend type",t,H("implements ",W(n," & ")),W(r," "),J(i)]," ")},InterfaceTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend interface",t,W(n," "),J(r)]," ")},UnionTypeExtension:function(e){var t=e.name,n=e.directives,r=e.types;return W(["extend union",t,W(n," "),r&&0!==r.length?"= "+W(r," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,n=e.directives,r=e.values;return W(["extend enum",t,W(n," "),J(r)]," ")},InputObjectTypeExtension:function(e){var t=e.name,n=e.directives,r=e.fields;return W(["extend input",t,W(n," "),J(r)]," ")}};function Y(e){return function(t){return W([t.description,e(t)],"\n")}}function W(e,t){return e?e.filter((function(e){return e})).join(t||""):""}function J(e){return e&&0!==e.length?"{\n"+X(W(e,"\n"))+"\n}":""}function H(e,t,n){return t?e+t+(n||""):""}function X(e){return e&&" "+e.replace(/\n/g,"\n ")}function Z(e){return-1!==e.indexOf("\n")}function ee(e){return e&&e.some(Z)}var te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ne(e,t){return e(t={exports:{}},t.exports),t.exports}var re=ne((function(e,t){var n="[object Arguments]",r="[object Map]",i="[object Object]",o="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[r]=u["[object Number]"]=u[i]=u["[object RegExp]"]=u[o]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof te&&te&&te.Object===Object&&te,l="object"==typeof self&&self&&self.Object===Object&&self,f=c||l||Function("return this")(),p=t&&!t.nodeType&&t,h=p&&e&&!e.nodeType&&e,d=h&&h.exports===p,v=d&&c.process,y=function(){try{return v&&v.binding&&v.binding("util")}catch(e){}}(),m=y&&y.isTypedArray;function g(e,t){for(var n=-1,r=null==e?0:e.length;++ns))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var l=-1,f=!0,p=2&n?new oe:void 0;for(o.set(e,t),o.set(t,e);++l-1},re.prototype.set=function(e,t){var n=this.__data__,r=ue(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new ne,map:new(B||re),string:new ne}},ie.prototype.delete=function(e){var t=ye(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return ye(this,e).get(e)},ie.prototype.has=function(e){return ye(this,e).has(e)},ie.prototype.set=function(e,t){var n=ye(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},oe.prototype.add=oe.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},oe.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.clear=function(){this.__data__=new re,this.size=0},ae.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ae.prototype.get=function(e){return this.__data__.get(e)},ae.prototype.has=function(e){return this.__data__.has(e)},ae.prototype.set=function(e,t){var n=this.__data__;if(n instanceof re){var r=n.__data__;if(!B||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ie(r)}return n.set(e,t),this.size=n.size,this};var ge=P?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}function Ie(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function xe(e){return null!=e&&"object"==typeof e}var De=m?function(e){return function(t){return e(t)}}(m):function(e){return xe(e)&&Te(e.length)&&!!u[ce(e)]};function Ae(e){return null!=(t=e)&&Te(t.length)&&!Se(t)?se(e):he(e);var t}e.exports=function(e,t){return fe(e,t)}})),ie=ne((function(e,t){var n="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",o="[object Map]",a="[object Set]",s=/\w*$/,u=/^\[object .+?Constructor\]$/,c=/^(?:0|[1-9]\d*)$/,l={};l[n]=l["[object Array]"]=l["[object ArrayBuffer]"]=l["[object DataView]"]=l["[object Boolean]"]=l["[object Date]"]=l["[object Float32Array]"]=l["[object Float64Array]"]=l["[object Int8Array]"]=l["[object Int16Array]"]=l["[object Int32Array]"]=l[o]=l["[object Number]"]=l["[object Object]"]=l["[object RegExp]"]=l[a]=l["[object String]"]=l["[object Symbol]"]=l["[object Uint8Array]"]=l["[object Uint8ClampedArray]"]=l["[object Uint16Array]"]=l["[object Uint32Array]"]=!0,l["[object Error]"]=l[r]=l["[object WeakMap]"]=!1;var f="object"==typeof te&&te&&te.Object===Object&&te,p="object"==typeof self&&self&&self.Object===Object&&self,h=f||p||Function("return this")(),d=t&&!t.nodeType&&t,v=d&&e&&!e.nodeType&&e,y=v&&v.exports===d;function m(e,t){return e.set(t[0],t[1]),e}function g(e,t){return e.add(t),e}function b(e,t,n,r){var i=-1,o=e?e.length:0;for(r&&o&&(n=e[++i]);++i-1},oe.prototype.set=function(e,t){var n=this.__data__,r=le(n,e);return r<0?n.push([e,t]):n[r][1]=t,this},ae.prototype.clear=function(){this.__data__={hash:new ie,map:new(G||oe),string:new ie}},ae.prototype.delete=function(e){return ve(this,e).delete(e)},ae.prototype.get=function(e){return ve(this,e).get(e)},ae.prototype.has=function(e){return ve(this,e).has(e)},ae.prototype.set=function(e,t){return ve(this,e).set(e,t),this},se.prototype.clear=function(){this.__data__=new oe},se.prototype.delete=function(e){return this.__data__.delete(e)},se.prototype.get=function(e){return this.__data__.get(e)},se.prototype.has=function(e){return this.__data__.has(e)},se.prototype.set=function(e,t){var n=this.__data__;if(n instanceof oe){var r=n.__data__;if(!G||r.length<199)return r.push([e,t]),this;n=this.__data__=new ae(r)}return n.set(e,t),this};var me=L?_(L,Object):function(){return[]},ge=function(e){return R.call(e)};function be(e,t){return!!(t=null==t?9007199254740991:t)&&("number"==typeof e||c.test(e))&&e>-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!Se(e)}var Ne=$||function(){return!1};function Se(e){var t=Te(e)?R.call(e):"";return t==r||t==i}function Te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ie(e){return ke(e)?ue(e):function(e){if(!Ee(e))return B(e);var t=[];for(var n in Object(e))A.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e)}e.exports=function(e){return fe(e,!1,!0)}})),oe=ne((function(e,t){!function(t,n){e.exports=n()}(0,(function(){var e=[],t=[],n={},r={},i={};function o(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function a(e,t){return e===t?t:e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function s(e,t){return e.replace(/\$(\d{1,2})/g,(function(e,n){return t[n]||""}))}function u(e,t){return e.replace(t[0],(function(n,r){var i=s(t[1],arguments);return a(""===n?e[r-1]:n,i)}))}function c(e,t,r){if(!e.length||n.hasOwnProperty(e))return t;for(var i=r.length;i--;){var o=r[i];if(o[0].test(t))return u(t,o)}return t}function l(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?a(r,i):e.hasOwnProperty(i)?a(r,e[i]):c(i,r,n)}}function f(e,t,n,r){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&c(i,i,n)===i}}function p(e,t,n){return(n?t+" ":"")+(1===t?p.singular(e):p.plural(e))}return p.plural=l(i,r,e),p.isPlural=f(i,r,e),p.singular=l(r,i,t),p.isSingular=f(r,i,t),p.addPluralRule=function(t,n){e.push([o(t),n])},p.addSingularRule=function(e,n){t.push([o(e),n])},p.addUncountableRule=function(e){"string"!=typeof e?(p.addPluralRule(e,"$0"),p.addSingularRule(e,"$0")):n[e.toLowerCase()]=!0},p.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),i[e]=t,r[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["whiskey","whiskies"]].forEach((function(e){return p.addIrregularRule(e[0],e[1])})),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|tlas|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[emjzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/(m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach((function(e){return p.addPluralRule(e[0],e[1])})),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/(m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|tlas|gas|(?:her|at|gr)o|ris)(?:es)?$/i,"$1"],[/(analy|ba|diagno|parenthe|progno|synop|the|empha|cri)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|octop|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach((function(e){return p.addSingularRule(e[0],e[1])})),["adulthood","advice","agenda","aid","alcohol","ammo","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","flounder","fun","gallows","garbage","graffiti","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","manga","news","pike","plankton","pliers","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","species","staff","swine","tennis","traffic","transporation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(p.addUncountableRule),p}))})),ae=oe.plural,se=oe.singular;function ue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ce(e){return e.charAt(0).toLowerCase()+e.slice(1)}function le(e){return z(fe(e))}function fe(e){return"string"==typeof e?C(e):e}function pe(e){return e.loc.source.body}function he(e){return null!==e&&!(e instanceof Array)&&"object"==typeof e}function de(e,t){if(!e)return{};for(var n=-1,r=t.length,i={};++n=0)return!0;var t=_r.getInstance(),n=!1;return this.getRelations().forEach((function(r){return!(r instanceof t.components.BelongsTo||r instanceof t.components.HasOne)||r.foreignKey!==e||(n=!0,!1)})),n},e.prototype.getRelations=function(){var t=new Map;return this.fields.forEach((function(n,r){e.isFieldAttribute(n)||t.set(r,n)})),t},e.prototype.isTypeFieldOfPolymorphicRelation=function(e){var t=this,n=_r.getInstance(),r=!1;return n.models.forEach((function(i){return!r&&(i.getRelations().forEach((function(i){if(i instanceof n.components.MorphMany||i instanceof n.components.MorphedByMany||i instanceof n.components.MorphOne||i instanceof n.components.MorphTo||i instanceof n.components.MorphToMany){var o=i.related;if(i.type===e&&o&&o.entity===t.baseModel.entity)return r=!0,!1}return!0})),!0)})),r},e.prototype.getRecordWithId=function(e){return this.baseModel.query().withAllRecursive().where("id",me(e)).first()},e.prototype.shouldEagerLoadRelation=function(e,t,n){var r=_r.getInstance();if(t instanceof r.components.HasOne||t instanceof r.components.BelongsTo||t instanceof r.components.MorphOne)return!0;var i=this.baseModel.eagerLoad||[];return Array.prototype.push.apply(i,this.baseModel.eagerSync||[]),void 0!==i.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.shouldEagerSaveRelation=function(e,t,n){if(t instanceof _r.getInstance().components.BelongsTo)return!0;var r=this.baseModel.eagerSave||[];return Array.prototype.push.apply(r,this.baseModel.eagerSync||[]),void 0!==r.find((function(t){return t===n.singularName||t===n.pluralName||t===e}))},e.prototype.$addMock=function(e){return!this.$findMock(e.action,e.options)&&(this.mocks[e.action]||(this.mocks[e.action]=[]),this.mocks[e.action].push(e),!0)},e.prototype.$findMock=function(e,t){return this.mocks[e]&&this.mocks[e].find((function(e){return!e.options||!t||ve(de(t,Object.keys(e.options)),e.options||{})}))||null},e.prototype.$mockHook=function(e,t){var n,r=null,i=this.$findMock(e,t);return i&&(r=i.returnValue instanceof Function?i.returnValue():i.returnValue||null),r?(r instanceof Array?r.forEach((function(e){return e.$isPersisted=!0})):r.$isPersisted=!0,(n={})[this.pluralName]=r,n):null},e}(),Ee=Object.setPrototypeOf,we=void 0===Ee?function(e,t){return e.__proto__=t,e}:Ee,_e=function(e){function t(n){void 0===n&&(n="Invariant Violation");var r=e.call(this,"number"==typeof n?"Invariant Violation: "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name="Invariant Violation",we(r,t.prototype),r}return n(t,e),t}(Error);function Oe(e,t){if(!e)throw new _e(t)}function ke(e){return function(){return console[e].apply(console,arguments)}}!function(e){e.warn=ke("warn"),e.error=ke("error")}(Oe||(Oe={}));var Ne={env:{}};if("object"==typeof process)Ne=process;else try{Function("stub","process = stub")(Ne)}catch(e){}var Se=Object.prototype,Te=Se.toString,Ie=Se.hasOwnProperty,xe=new Map;function De(e,t){try{return function e(t,n){if(t===n)return!0;var r=Te.call(t),i=Te.call(n);if(r!==i)return!1;switch(r){case"[object Array]":if(t.length!==n.length)return!1;case"[object Object]":if(Ae(t,n))return!0;var o=Object.keys(t),a=Object.keys(n),s=o.length;if(s!==a.length)return!1;for(var u=0;u0){var r=n.connection.filter?n.connection.filter:[];r.sort();var i=t,o={};return r.forEach((function(e){o[e]=i[e]})),n.connection.key+"("+JSON.stringify(o)+")"}return n.connection.key}var a=e;if(t){var s=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,r="boolean"==typeof t.cycles&&t.cycles,i=t.cmp&&(n=t.cmp,function(e){return function(t,r){var i={key:t,value:e[t]},o={key:r,value:e[r]};return n(i,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,a;if(Array.isArray(t)){for(a="[",n=0;n-1}))}function Ue(e){return e&&Be(["client"],e)&&Be(["export"],e)}function Ge(e){var t=e.name.value;return"skip"===t||"include"===t}function ze(e,t){var n=t,i=[];return e.definitions.forEach((function(e){if("OperationDefinition"===e.kind)throw"production"===process.env.NODE_ENV?new _e(5):new _e("Found a "+e.operation+" operation"+(e.name?" named '"+e.name.value+"'":"")+". No operations are allowed when using a fragment as a query. Only fragments are allowed.");"FragmentDefinition"===e.kind&&i.push(e)})),void 0===n&&("production"===process.env.NODE_ENV?Oe(1===i.length,6):Oe(1===i.length,"Found "+i.length+" fragments. `fragmentName` must be provided when there is not exactly 1 fragment."),n=i[0].name.value),r(r({},e),{definitions:a([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:n}}]}}],e.definitions)})}function Ke(e){for(var t=[],n=1;n1){var r=[];t=wt(t,r);for(var i=1;i1,i=!1,o=arguments[1],a=o;return new n((function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(new TypeError("Cannot reduce an empty sequence"));n.next(a),n.complete()}})}))}},{key:"concat",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r=0&&i.splice(e,1),a()}});i.push(o)},error:function(e){r.error(e)},complete:function(){a()}});function a(){o.closed&&0===i.length&&r.complete()}return function(){i.forEach((function(e){return e.unsubscribe()})),o.unsubscribe()}}))}},{key:c,value:function(){return this}}],[{key:"from",value:function(t){var n="function"==typeof this?this:e;if(null==t)throw new TypeError(t+" is not an object");var r=f(t,c);if(r){var i=r.call(t);if(Object(i)!==i)throw new TypeError(i+" is not an object");return h(i)&&i.constructor===n?i:new n((function(e){return i.subscribe(e)}))}if(a("iterator")&&(r=f(t,u)))return new n((function(e){v((function(){if(!e.closed){var n=!0,i=!1,o=void 0;try{for(var a,s=r.call(t)[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var u=a.value;if(e.next(u),e.closed)return}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}e.complete()}}))}));if(Array.isArray(t))return new n((function(e){v((function(){if(!e.closed){for(var n=0;n0}var $t,Bt=function(e){function t(n){var r,i,o=n.graphQLErrors,a=n.networkError,s=n.errorMessage,u=n.extraInfo,c=e.call(this,s)||this;return c.graphQLErrors=o||[],c.networkError=a||null,c.message=s||(i="",Lt((r=c).graphQLErrors)&&r.graphQLErrors.forEach((function(e){var t=e?e.message:"Error message not found.";i+="GraphQL error: "+t+"\n"})),r.networkError&&(i+="Network error: "+r.networkError.message+"\n"),i=i.replace(/\n$/,"")),c.extraInfo=u,c.__proto__=t.prototype,c}return n(t,e),t}(Error);!function(e){e[e.normal=1]="normal",e[e.refetch=2]="refetch",e[e.poll=3]="poll"}($t||($t={}));var Ut=function(e){function t(t){var n=t.queryManager,r=t.options,i=t.shouldSubscribe,o=void 0===i||i,a=e.call(this,(function(e){return a.onSubscribe(e)}))||this;a.observers=new Set,a.subscriptions=new Set,a.isTornDown=!1,a.options=r,a.variables=r.variables||{},a.queryId=n.generateQueryId(),a.shouldSubscribe=o;var s=We(r.query);return a.queryName=s&&s.name&&s.name.value,a.queryManager=n,a}return n(t,e),t.prototype.result=function(){var e=this;return new Promise((function(t,n){var r={next:function(n){t(n),e.observers.delete(r),e.observers.size||e.queryManager.removeQuery(e.queryId),setTimeout((function(){i.unsubscribe()}),0)},error:n},i=e.subscribe(r)}))},t.prototype.currentResult=function(){var e=this.getCurrentResult();return void 0===e.data&&(e.data={}),e},t.prototype.getCurrentResult=function(){if(this.isTornDown){var e=this.lastResult;return{data:!this.lastError&&e&&e.data||void 0,error:this.lastError,loading:!1,networkStatus:Qt.error}}var t,n,i,o=this.queryManager.getCurrentQueryResult(this),a=o.data,s=o.partial,u=this.queryManager.queryStore.get(this.queryId),c=this.options.fetchPolicy,l="network-only"===c||"no-cache"===c;if(u){var f=u.networkStatus;if(n=u,void 0===(i=this.options.errorPolicy)&&(i="none"),n&&(n.networkError||"none"===i&&Lt(n.graphQLErrors)))return{data:void 0,loading:!1,networkStatus:f,error:new Bt({graphQLErrors:u.graphQLErrors,networkError:u.networkError})};u.variables&&(this.options.variables=r(r({},this.options.variables),u.variables),this.variables=this.options.variables),t={data:a,loading:Pt(f),networkStatus:f},u.graphQLErrors&&"all"===this.options.errorPolicy&&(t.errors=u.graphQLErrors)}else{var p=l||s&&"cache-only"!==c;t={data:a,loading:p,networkStatus:p?Qt.loading:Qt.ready}}return s||this.updateLastResult(r(r({},t),{stale:!1})),r(r({},t),{partial:s})},t.prototype.isDifferentFromLastResult=function(e){var t=this.lastResultSnapshot;return!(t&&e&&t.networkStatus===e.networkStatus&&t.stale===e.stale&&De(t.data,e.data))},t.prototype.getLastResult=function(){return this.lastResult},t.prototype.getLastError=function(){return this.lastError},t.prototype.resetLastResults=function(){delete this.lastResult,delete this.lastResultSnapshot,delete this.lastError,this.isTornDown=!1},t.prototype.resetQueryStoreErrors=function(){var e=this.queryManager.queryStore.get(this.queryId);e&&(e.networkError=null,e.graphQLErrors=[])},t.prototype.refetch=function(e){var t=this.options.fetchPolicy;return"cache-only"===t?Promise.reject("production"===process.env.NODE_ENV?new _e(3):new _e("cache-only fetchPolicy option should not be used together with query refetch.")):("no-cache"!==t&&"cache-and-network"!==t&&(t="network-only"),De(this.variables,e)||(this.variables=r(r({},this.variables),e)),De(this.options.variables,this.variables)||(this.options.variables=r(r({},this.options.variables),this.variables)),this.queryManager.fetchQuery(this.queryId,r(r({},this.options),{fetchPolicy:t}),$t.refetch))},t.prototype.fetchMore=function(e){var t=this;"production"===process.env.NODE_ENV?Oe(e.updateQuery,4):Oe(e.updateQuery,"updateQuery option is required. This function defines how to update the query data with the new results.");var n=r(r({},e.query?e:r(r(r({},this.options),e),{variables:r(r({},this.variables),e.variables)})),{fetchPolicy:"network-only"}),i=this.queryManager.generateQueryId();return this.queryManager.fetchQuery(i,n,$t.normal,this.queryId).then((function(r){return t.updateQuery((function(t){return e.updateQuery(t,{fetchMoreResult:r.data,variables:n.variables})})),t.queryManager.stopQuery(i),r}),(function(e){throw t.queryManager.stopQuery(i),e}))},t.prototype.subscribeToMore=function(e){var t=this,n=this.queryManager.startGraphQLSubscription({query:e.document,variables:e.variables}).subscribe({next:function(n){var r=e.updateQuery;r&&t.updateQuery((function(e,t){var i=t.variables;return r(e,{subscriptionData:n,variables:i})}))},error:function(t){e.onError?e.onError(t):"production"===process.env.NODE_ENV||Oe.error("Unhandled GraphQL subscription error",t)}});return this.subscriptions.add(n),function(){t.subscriptions.delete(n)&&n.unsubscribe()}},t.prototype.setOptions=function(e){var t=this.options.fetchPolicy;this.options=r(r({},this.options),e),e.pollInterval?this.startPolling(e.pollInterval):0===e.pollInterval&&this.stopPolling();var n=e.fetchPolicy;return this.setVariables(this.options.variables,t!==n&&("cache-only"===t||"standby"===t||"network-only"===n),e.fetchResults)},t.prototype.setVariables=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=!0),this.isTornDown=!1,e=e||this.variables,!t&&De(e,this.variables)?this.observers.size&&n?this.result():Promise.resolve():(this.variables=this.options.variables=e,this.observers.size?this.queryManager.fetchQuery(this.queryId,this.options):Promise.resolve())},t.prototype.updateQuery=function(e){var t=this.queryManager,n=t.getQueryWithPreviousResult(this.queryId),r=n.previousResult,i=n.variables,o=n.document,a=ht((function(){return e(r,{variables:i})}));a&&(t.dataStore.markUpdateQueryResult(o,i,a),t.broadcastQueries())},t.prototype.stopPolling=function(){this.queryManager.stopPollingQuery(this.queryId),this.options.pollInterval=void 0},t.prototype.startPolling=function(e){Kt(this),this.options.pollInterval=e,this.queryManager.startPollingQuery(this.options,this.queryId)},t.prototype.updateLastResult=function(e){var t=this.lastResult;return this.lastResult=e,this.lastResultSnapshot=this.queryManager.assumeImmutableResults?e:lt(e),t},t.prototype.onSubscribe=function(e){var t=this;try{var n=e._subscription._observer;n&&!n.error&&(n.error=Gt)}catch(e){}var r=!this.observers.size;return this.observers.add(e),e.next&&this.lastResult&&e.next(this.lastResult),e.error&&this.lastError&&e.error(this.lastError),r&&this.setUpQuery(),function(){t.observers.delete(e)&&!t.observers.size&&t.tearDownQuery()}},t.prototype.setUpQuery=function(){var e=this,t=this.queryManager,n=this.queryId;this.shouldSubscribe&&t.addObservableQuery(n,this),this.options.pollInterval&&(Kt(this),t.startPollingQuery(this.options,n));var i=function(t){e.updateLastResult(r(r({},e.lastResult),{errors:t.graphQLErrors,networkStatus:Qt.error,loading:!1})),zt(e.observers,"error",e.lastError=t)};t.observeQuery(n,this.options,{next:function(n){if(e.lastError||e.isDifferentFromLastResult(n)){var r=e.updateLastResult(n),i=e.options,o=i.query,a=i.variables,s=i.fetchPolicy;t.transform(o).hasClientExports?t.getLocalState().addExportedVariables(o,a).then((function(i){var a=e.variables;e.variables=e.options.variables=i,!n.loading&&r&&"cache-only"!==s&&t.transform(o).serverQuery&&!De(a,i)?e.refetch():zt(e.observers,"next",n)})):zt(e.observers,"next",n)}},error:i}).catch(i)},t.prototype.tearDownQuery=function(){var e=this.queryManager;this.isTornDown=!0,e.stopPollingQuery(this.queryId),this.subscriptions.forEach((function(e){return e.unsubscribe()})),this.subscriptions.clear(),e.removeObservableQuery(this.queryId),e.stopQuery(this.queryId),this.observers.clear()},t}(Vt);function Gt(e){"production"===process.env.NODE_ENV||Oe.error("Unhandled error",e.message,e.stack)}function zt(e,t,n){var r=[];e.forEach((function(e){return e[t]&&r.push(e)})),r.forEach((function(e){return e[t](n)}))}function Kt(e){var t=e.options.fetchPolicy;"production"===process.env.NODE_ENV?Oe("cache-first"!==t&&"cache-only"!==t,5):Oe("cache-first"!==t&&"cache-only"!==t,"Queries that specify the cache-first and cache-only fetchPolicies cannot also be polling queries.")}var Yt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initMutation=function(e,t,n){this.store[e]={mutation:t,variables:n||{},loading:!0,error:null}},e.prototype.markMutationError=function(e,t){var n=this.store[e];n&&(n.loading=!1,n.error=t)},e.prototype.markMutationResult=function(e){var t=this.store[e];t&&(t.loading=!1,t.error=null)},e.prototype.reset=function(){this.store={}},e}(),Wt=function(){function e(){this.store={}}return e.prototype.getStore=function(){return this.store},e.prototype.get=function(e){return this.store[e]},e.prototype.initQuery=function(e){var t=this.store[e.queryId];"production"===process.env.NODE_ENV?Oe(!t||t.document===e.document||De(t.document,e.document),19):Oe(!t||t.document===e.document||De(t.document,e.document),"Internal Error: may not update existing query string in store");var n,r=!1,i=null;e.storePreviousVariables&&t&&t.networkStatus!==Qt.loading&&(De(t.variables,e.variables)||(r=!0,i=t.variables)),n=r?Qt.setVariables:e.isPoll?Qt.poll:e.isRefetch?Qt.refetch:Qt.loading;var o=[];t&&t.graphQLErrors&&(o=t.graphQLErrors),this.store[e.queryId]={document:e.document,variables:e.variables,previousVariables:i,networkError:null,graphQLErrors:o,networkStatus:n,metadata:e.metadata},"string"==typeof e.fetchMoreForQueryId&&this.store[e.fetchMoreForQueryId]&&(this.store[e.fetchMoreForQueryId].networkStatus=Qt.fetchMore)},e.prototype.markQueryResult=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=null,this.store[e].graphQLErrors=Lt(t.errors)?t.errors:[],this.store[e].previousVariables=null,this.store[e].networkStatus=Qt.ready,"string"==typeof n&&this.store[n]&&(this.store[n].networkStatus=Qt.ready))},e.prototype.markQueryError=function(e,t,n){this.store&&this.store[e]&&(this.store[e].networkError=t,this.store[e].networkStatus=Qt.error,"string"==typeof n&&this.markQueryResultClient(n,!0))},e.prototype.markQueryResultClient=function(e,t){var n=this.store&&this.store[e];n&&(n.networkError=null,n.previousVariables=null,t&&(n.networkStatus=Qt.ready))},e.prototype.stopQuery=function(e){delete this.store[e]},e.prototype.reset=function(e){var t=this;Object.keys(this.store).forEach((function(n){e.indexOf(n)<0?t.stopQuery(n):t.store[n].networkStatus=Qt.loading}))},e}();var Jt=function(){function e(e){var t=e.cache,n=e.client,r=e.resolvers,i=e.fragmentMatcher;this.cache=t,n&&(this.client=n),r&&this.addResolvers(r),i&&this.setFragmentMatcher(i)}return e.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach((function(e){t.resolvers=mt(t.resolvers,e)})):this.resolvers=mt(this.resolvers,e)},e.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},e.prototype.getResolvers=function(){return this.resolvers||{}},e.prototype.runResolvers=function(e){var t=e.document,n=e.remoteResult,a=e.context,s=e.variables,u=e.onlyRunForcedResolvers,c=void 0!==u&&u;return i(this,void 0,void 0,(function(){return o(this,(function(e){return t?[2,this.resolveDocument(t,n.data,a,s,this.fragmentMatcher,c).then((function(e){return r(r({},n),{data:e.result})}))]:[2,n]}))}))},e.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},e.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},e.prototype.clientQuery=function(e){if(Be(["client"],e)){if(this.resolvers)return e;"production"===process.env.NODE_ENV||Oe.warn("Found @client directives in a query but no ApolloClient resolvers were specified. This means ApolloClient local resolver handling has been disabled, and @client directives will be passed through to your link chain.")}return null},e.prototype.serverQuery=function(e){return this.resolvers?function(e){Ye(e);var t=ot([{test:function(e){return"client"===e.name.value},remove:!0}],e);return t&&(t=B(t,{FragmentDefinition:{enter:function(e){if(e.selectionSet&&e.selectionSet.selections.every((function(e){return Qe(e)&&"__typename"===e.name.value})))return null}}})),t}(e):e},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.cache;return r(r({},e),{cache:t,getCacheKey:function(e){if(t.config)return t.config.dataIdFromObject(e);"production"===process.env.NODE_ENV?Oe(!1,6):Oe(!1,"To use context.getCacheKey, you need to use a cache that has a configurable dataIdFromObject, like apollo-cache-inmemory.")}})},e.prototype.addExportedVariables=function(e,t,n){return void 0===t&&(t={}),void 0===n&&(n={}),i(this,void 0,void 0,(function(){return o(this,(function(i){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(n),t).then((function(e){return r(r({},t),e.exportedVariables)}))]:[2,r({},t)]}))}))},e.prototype.shouldForceResolvers=function(e){var t=!1;return B(e,{Directive:{enter:function(e){if("client"===e.name.value&&e.arguments&&(t=e.arguments.some((function(e){return"always"===e.name.value&&"BooleanValue"===e.value.kind&&!0===e.value.value}))))return $}}}),t},e.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:st(e),variables:t,returnPartialData:!0,optimistic:!1}).result},e.prototype.resolveDocument=function(e,t,n,a,s,u){return void 0===n&&(n={}),void 0===a&&(a={}),void 0===s&&(s=function(){return!0}),void 0===u&&(u=!1),i(this,void 0,void 0,(function(){var i,c,l,f,p,h,d,v,y;return o(this,(function(o){var m;return i=Xe(e),c=He(e),l=Ze(c),f=i.operation,p=f?(m=f).charAt(0).toUpperCase()+m.slice(1):"Query",d=(h=this).cache,v=h.client,y={fragmentMap:l,context:r(r({},n),{cache:d,client:v}),variables:a,fragmentMatcher:s,defaultOperationType:p,exportedVariables:{},onlyRunForcedResolvers:u},[2,this.resolveSelectionSet(i.selectionSet,t,y).then((function(e){return{result:e,exportedVariables:y.exportedVariables}}))]}))}))},e.prototype.resolveSelectionSet=function(e,t,n){return i(this,void 0,void 0,(function(){var r,a,s,u,c,l=this;return o(this,(function(f){return r=n.fragmentMap,a=n.context,s=n.variables,u=[t],c=function(e){return i(l,void 0,void 0,(function(){var i,c;return o(this,(function(o){return $e(e,s)?Qe(e)?[2,this.resolveField(e,t,n).then((function(t){var n;void 0!==t&&u.push(((n={})[Ce(e)]=t,n))}))]:(qe(e)?i=e:(i=r[e.name.value],"production"===process.env.NODE_ENV?Oe(i,7):Oe(i,"No fragment named "+e.name.value)),i&&i.typeCondition&&(c=i.typeCondition.name.value,n.fragmentMatcher(t,c,a))?[2,this.resolveSelectionSet(i.selectionSet,t,n).then((function(e){u.push(e)}))]:[2]):[2]}))}))},[2,Promise.all(e.selections.map(c)).then((function(){return gt(u)}))]}))}))},e.prototype.resolveField=function(e,t,n){return i(this,void 0,void 0,(function(){var r,i,a,s,u,c,l,f,p,h=this;return o(this,(function(o){return r=n.variables,i=e.name.value,a=Ce(e),s=i!==a,u=t[a]||t[i],c=Promise.resolve(u),n.onlyRunForcedResolvers&&!this.shouldForceResolvers(e)||(l=t.__typename||n.defaultOperationType,(f=this.resolvers&&this.resolvers[l])&&(p=f[s?i:a])&&(c=Promise.resolve(p(t,je(e,r),n.context,{field:e,fragmentMap:n.fragmentMap})))),[2,c.then((function(t){return void 0===t&&(t=u),e.directives&&e.directives.forEach((function(e){"export"===e.name.value&&e.arguments&&e.arguments.forEach((function(e){"as"===e.name.value&&"StringValue"===e.value.kind&&(n.exportedVariables[e.value.value]=t)}))})),e.selectionSet?null==t?t:Array.isArray(t)?h.resolveSubSelectedArray(e,t,n):e.selectionSet?h.resolveSelectionSet(e.selectionSet,t,n):void 0:t}))]}))}))},e.prototype.resolveSubSelectedArray=function(e,t,n){var r=this;return Promise.all(t.map((function(t){return null===t?null:Array.isArray(t)?r.resolveSubSelectedArray(e,t,n):e.selectionSet?r.resolveSelectionSet(e.selectionSet,t,n):void 0})))},e}();function Ht(e){var t=new Set,n=null;return new Vt((function(r){return t.add(r),n=n||e.subscribe({next:function(e){t.forEach((function(t){return t.next&&t.next(e)}))},error:function(e){t.forEach((function(t){return t.error&&t.error(e)}))},complete:function(){t.forEach((function(e){return e.complete&&e.complete()}))}}),function(){t.delete(r)&&!t.size&&n&&(n.unsubscribe(),n=null)}}))}var Xt=Object.prototype.hasOwnProperty,Zt=function(){function e(e){var t=e.link,n=e.queryDeduplication,r=void 0!==n&&n,i=e.store,o=e.onBroadcast,a=void 0===o?function(){}:o,s=e.ssrMode,u=void 0!==s&&s,c=e.clientAwareness,l=void 0===c?{}:c,f=e.localState,p=e.assumeImmutableResults;this.mutationStore=new Yt,this.queryStore=new Wt,this.clientAwareness={},this.idCounter=1,this.queries=new Map,this.fetchQueryRejectFns=new Map,this.transformCache=new(ut?WeakMap:Map),this.inFlightLinkObservables=new Map,this.pollingInfoByQueryId=new Map,this.link=t,this.queryDeduplication=r,this.dataStore=i,this.onBroadcast=a,this.clientAwareness=l,this.localState=f||new Jt({cache:i.getCache()}),this.ssrMode=u,this.assumeImmutableResults=!!p}return e.prototype.stop=function(){var e=this;this.queries.forEach((function(t,n){e.stopQueryNoBroadcast(n)})),this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(8):new _e("QueryManager stopped while query was in flight"))}))},e.prototype.mutate=function(e){var t=e.mutation,n=e.variables,a=e.optimisticResponse,s=e.updateQueries,u=e.refetchQueries,c=void 0===u?[]:u,l=e.awaitRefetchQueries,f=void 0!==l&&l,p=e.update,h=e.errorPolicy,d=void 0===h?"none":h,v=e.fetchPolicy,y=e.context,m=void 0===y?{}:y;return i(this,void 0,void 0,(function(){var e,i,u,l=this;return o(this,(function(o){switch(o.label){case 0:return"production"===process.env.NODE_ENV?Oe(t,9):Oe(t,"mutation option is required. You must specify your GraphQL document in the mutation option."),"production"===process.env.NODE_ENV?Oe(!v||"no-cache"===v,10):Oe(!v||"no-cache"===v,"Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior."),e=this.generateQueryId(),t=this.transform(t).document,this.setQuery(e,(function(){return{document:t}})),n=this.getVariables(t,n),this.transform(t).hasClientExports?[4,this.localState.addExportedVariables(t,n,m)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return i=function(){var e={};return s&&l.queries.forEach((function(t,n){var r=t.observableQuery;if(r){var i=r.queryName;i&&Xt.call(s,i)&&(e[n]={updater:s[i],query:l.queryStore.get(n)})}})),e},this.mutationStore.initMutation(e,t,n),this.dataStore.markMutationInit({mutationId:e,document:t,variables:n,updateQueries:i(),update:p,optimisticResponse:a}),this.broadcastQueries(),u=this,[2,new Promise((function(o,s){var l,h;u.getObservableFromLink(t,r(r({},m),{optimisticResponse:a}),n,!1).subscribe({next:function(r){dt(r)&&"none"===d?h=new Bt({graphQLErrors:r.errors}):(u.mutationStore.markMutationResult(e),"no-cache"!==v&&u.dataStore.markMutationResult({mutationId:e,result:r,document:t,variables:n,updateQueries:i(),update:p}),l=r)},error:function(t){u.mutationStore.markMutationError(e,t),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),u.setQuery(e,(function(){return{document:null}})),s(new Bt({networkError:t}))},complete:function(){if(h&&u.mutationStore.markMutationError(e,h),u.dataStore.markMutationComplete({mutationId:e,optimisticResponse:a}),u.broadcastQueries(),h)s(h);else{"function"==typeof c&&(c=c(l));var t=[];Lt(c)&&c.forEach((function(e){if("string"==typeof e)u.queries.forEach((function(n){var r=n.observableQuery;r&&r.queryName===e&&t.push(r.refetch())}));else{var n={query:e.query,variables:e.variables,fetchPolicy:"network-only"};e.context&&(n.context=e.context),t.push(u.query(n))}})),Promise.all(f?t:[]).then((function(){u.setQuery(e,(function(){return{document:null}})),"ignore"===d&&l&&dt(l)&&delete l.errors,o(l)}))}}})}))]}}))}))},e.prototype.fetchQuery=function(e,t,n,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d,v,y,m,g,b,E,w,_,O,k=this;return o(this,(function(o){switch(o.label){case 0:return i=t.metadata,s=void 0===i?null:i,u=t.fetchPolicy,c=void 0===u?"cache-first":u,l=t.context,f=void 0===l?{}:l,p=this.transform(t.query).document,h=this.getVariables(p,t.variables),this.transform(p).hasClientExports?[4,this.localState.addExportedVariables(p,h,f)]:[3,2];case 1:h=o.sent(),o.label=2;case 2:if(t=r(r({},t),{variables:h}),y=v="network-only"===c||"no-cache"===c,v||(m=this.dataStore.getCache().diff({query:p,variables:h,returnPartialData:!0,optimistic:!1}),g=m.complete,b=m.result,y=!g||"cache-and-network"===c,d=b),E=y&&"cache-only"!==c&&"standby"!==c,Be(["live"],p)&&(E=!0),w=this.idCounter++,_="no-cache"!==c?this.updateQueryWatch(e,p,t):void 0,this.setQuery(e,(function(){return{document:p,lastRequestId:w,invalidated:!0,cancel:_}})),this.invalidate(a),this.queryStore.initQuery({queryId:e,document:p,storePreviousVariables:E,variables:h,isPoll:n===$t.poll,isRefetch:n===$t.refetch,metadata:s,fetchMoreForQueryId:a}),this.broadcastQueries(),E){if(O=this.fetchRequest({requestId:w,queryId:e,document:p,options:t,fetchMoreForQueryId:a}).catch((function(t){throw t.hasOwnProperty("graphQLErrors")?t:(w>=k.getQuery(e).lastRequestId&&(k.queryStore.markQueryError(e,t,a),k.invalidate(e),k.invalidate(a),k.broadcastQueries()),new Bt({networkError:t}))})),"cache-and-network"!==c)return[2,O];O.catch((function(){}))}return this.queryStore.markQueryResultClient(e,!E),this.invalidate(e),this.invalidate(a),this.transform(p).hasForcedResolvers?[2,this.localState.runResolvers({document:p,remoteResult:{data:d},context:f,variables:h,onlyRunForcedResolvers:!0}).then((function(n){return k.markQueryResult(e,n,t,a),k.broadcastQueries(),n}))]:(this.broadcastQueries(),[2,{data:d}])}}))}))},e.prototype.markQueryResult=function(e,t,n,r){var i=n.fetchPolicy,o=n.variables,a=n.errorPolicy;"no-cache"===i?this.setQuery(e,(function(){return{newData:{result:t.data,complete:!0}}})):this.dataStore.markQueryResult(t,this.getQuery(e).document,o,r,"ignore"===a||"all"===a)},e.prototype.queryListenerForObserver=function(e,t,n){var r=this;function i(e,t){if(n[e])try{n[e](t)}catch(e){"production"===process.env.NODE_ENV||Oe.error(e)}else"error"===e&&("production"===process.env.NODE_ENV||Oe.error(t))}return function(n,o){if(r.invalidate(e,!1),n){var a=r.getQuery(e),s=a.observableQuery,u=a.document,c=s?s.options.fetchPolicy:t.fetchPolicy;if("standby"!==c){var l=Pt(n.networkStatus),f=s&&s.getLastResult(),p=!(!f||f.networkStatus===n.networkStatus),h=t.returnPartialData||!o&&n.previousVariables||p&&t.notifyOnNetworkStatusChange||"cache-only"===c||"cache-and-network"===c;if(!l||h){var d=Lt(n.graphQLErrors),v=s&&s.options.errorPolicy||t.errorPolicy||"none";if("none"===v&&d||n.networkError)return i("error",new Bt({graphQLErrors:n.graphQLErrors,networkError:n.networkError}));try{var y=void 0,m=void 0;if(o)"no-cache"!==c&&"network-only"!==c&&r.setQuery(e,(function(){return{newData:null}})),y=o.result,m=!o.complete;else{var g=s&&s.getLastError(),b="none"!==v&&(g&&g.graphQLErrors)!==n.graphQLErrors;if(f&&f.data&&!b)y=f.data,m=!1;else{var E=r.dataStore.getCache().diff({query:u,variables:n.previousVariables||n.variables,returnPartialData:!0,optimistic:!0});y=E.result,m=!E.complete}}var w=m&&!(t.returnPartialData||"cache-only"===c),_={data:w?f&&f.data:y,loading:l,networkStatus:n.networkStatus,stale:w};"all"===v&&d&&(_.errors=n.graphQLErrors),i("next",_)}catch(e){i("error",new Bt({networkError:e}))}}}}}},e.prototype.transform=function(e){var t,n=this.transformCache;if(!n.has(e)){var r=this.dataStore.getCache(),i=r.transformDocument(e),o=(t=r.transformForLink(i),ot([at],Ye(t))),a=this.localState.clientQuery(i),s=this.localState.serverQuery(o),u={document:i,hasClientExports:Ue(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:s,defaultVars:et(We(i))},c=function(e){e&&!n.has(e)&&n.set(e,u)};c(e),c(i),c(a),c(s)}return n.get(e)},e.prototype.getVariables=function(e,t){return r(r({},this.transform(e).defaultVars),t)},e.prototype.watchQuery=function(e,t){void 0===t&&(t=!0),"production"===process.env.NODE_ENV?Oe("standby"!==e.fetchPolicy,11):Oe("standby"!==e.fetchPolicy,'client.watchQuery cannot be called with fetchPolicy set to "standby"'),e.variables=this.getVariables(e.query,e.variables),void 0===e.notifyOnNetworkStatusChange&&(e.notifyOnNetworkStatusChange=!1);var n=r({},e);return new Ut({queryManager:this,options:n,shouldSubscribe:t})},e.prototype.query=function(e){var t=this;return"production"===process.env.NODE_ENV?Oe(e.query,12):Oe(e.query,"query option is required. You must specify your GraphQL document in the query option."),"production"===process.env.NODE_ENV?Oe("Document"===e.query.kind,13):Oe("Document"===e.query.kind,'You must wrap the query string in a "gql" tag.'),"production"===process.env.NODE_ENV?Oe(!e.returnPartialData,14):Oe(!e.returnPartialData,"returnPartialData option only supported on watchQuery."),"production"===process.env.NODE_ENV?Oe(!e.pollInterval,15):Oe(!e.pollInterval,"pollInterval option only supported on watchQuery."),new Promise((function(n,r){var i=t.watchQuery(e,!1);t.fetchQueryRejectFns.set("query:"+i.queryId,r),i.result().then(n,r).then((function(){return t.fetchQueryRejectFns.delete("query:"+i.queryId)}))}))},e.prototype.generateQueryId=function(){return String(this.idCounter++)},e.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryInStoreNoBroadcast=function(e){this.stopPollingQuery(e),this.queryStore.stopQuery(e),this.invalidate(e)},e.prototype.addQueryListener=function(e,t){this.setQuery(e,(function(e){return e.listeners.add(t),{invalidated:!1}}))},e.prototype.updateQueryWatch=function(e,t,n){var r=this,i=this.getQuery(e).cancel;i&&i();return this.dataStore.getCache().watch({query:t,variables:n.variables,optimistic:!0,previousResult:function(){var t=null,n=r.getQuery(e).observableQuery;if(n){var i=n.getLastResult();i&&(t=i.data)}return t},callback:function(t){r.setQuery(e,(function(){return{invalidated:!0,newData:t}}))}})},e.prototype.addObservableQuery=function(e,t){this.setQuery(e,(function(){return{observableQuery:t}}))},e.prototype.removeObservableQuery=function(e){var t=this.getQuery(e).cancel;this.setQuery(e,(function(){return{observableQuery:null}})),t&&t()},e.prototype.clearStore=function(){this.fetchQueryRejectFns.forEach((function(e){e("production"===process.env.NODE_ENV?new _e(16):new _e("Store reset while query was in flight (not completed in link chain)"))}));var e=[];return this.queries.forEach((function(t,n){t.observableQuery&&e.push(n)})),this.queryStore.reset(e),this.mutationStore.reset(),this.dataStore.reset()},e.prototype.resetStore=function(){var e=this;return this.clearStore().then((function(){return e.reFetchObservableQueries()}))},e.prototype.reFetchObservableQueries=function(e){var t=this;void 0===e&&(e=!1);var n=[];return this.queries.forEach((function(r,i){var o=r.observableQuery;if(o){var a=o.options.fetchPolicy;o.resetLastResults(),"cache-only"===a||!e&&"standby"===a||n.push(o.refetch()),t.setQuery(i,(function(){return{newData:null}})),t.invalidate(i)}})),this.broadcastQueries(),Promise.all(n)},e.prototype.observeQuery=function(e,t,n){return this.addQueryListener(e,this.queryListenerForObserver(e,t,n)),this.fetchQuery(e,t)},e.prototype.startQuery=function(e,t,n){return"production"===process.env.NODE_ENV||Oe.warn("The QueryManager.startQuery method has been deprecated"),this.addQueryListener(e,n),this.fetchQuery(e,t).catch((function(){})),e},e.prototype.startGraphQLSubscription=function(e){var t=this,n=e.query,r=e.fetchPolicy,i=e.variables;n=this.transform(n).document,i=this.getVariables(n,i);var o=function(e){return t.getObservableFromLink(n,{},e,!1).map((function(i){if(r&&"no-cache"===r||(t.dataStore.markSubscriptionResult(i,n,e),t.broadcastQueries()),dt(i))throw new Bt({graphQLErrors:i.errors});return i}))};if(this.transform(n).hasClientExports){var a=this.localState.addExportedVariables(n,i).then(o);return new Vt((function(e){var t=null;return a.then((function(n){return t=n.subscribe(e)}),e.error),function(){return t&&t.unsubscribe()}}))}return o(i)},e.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},e.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},e.prototype.removeQuery=function(e){this.fetchQueryRejectFns.delete("query:"+e),this.fetchQueryRejectFns.delete("fetchRequest:"+e),this.getQuery(e).subscriptions.forEach((function(e){return e.unsubscribe()})),this.queries.delete(e)},e.prototype.getCurrentQueryResult=function(e,t){void 0===t&&(t=!0);var n=e.options,r=n.variables,i=n.query,o=n.fetchPolicy,a=n.returnPartialData,s=e.getLastResult(),u=this.getQuery(e.queryId).newData;if(u&&u.complete)return{data:u.result,partial:!1};if("no-cache"===o||"network-only"===o)return{data:void 0,partial:!1};var c=this.dataStore.getCache().diff({query:i,variables:r,previousResult:s?s.data:void 0,returnPartialData:!0,optimistic:t}),l=c.result,f=c.complete;return{data:f||a?l:void 0,partial:!f}},e.prototype.getQueryWithPreviousResult=function(e){var t;if("string"==typeof e){var n=this.getQuery(e).observableQuery;"production"===process.env.NODE_ENV?Oe(n,17):Oe(n,"ObservableQuery with this id doesn't exist: "+e),t=n}else t=e;var r=t.options,i=r.variables,o=r.query;return{previousResult:this.getCurrentQueryResult(t,!1).data,variables:i,document:o}},e.prototype.broadcastQueries=function(){var e=this;this.onBroadcast(),this.queries.forEach((function(t,n){t.invalidated&&t.listeners.forEach((function(r){r&&r(e.queryStore.get(n),t.newData)}))}))},e.prototype.getLocalState=function(){return this.localState},e.prototype.getObservableFromLink=function(e,t,n,i){var o,a=this;void 0===i&&(i=this.queryDeduplication);var s=this.transform(e).serverQuery;if(s){var u=this.inFlightLinkObservables,c=this.link,l={query:s,variables:n,operationName:Je(s)||void 0,context:this.prepareContext(r(r({},t),{forceFetch:!i}))};if(t=l.context,i){var f=u.get(s)||new Map;u.set(s,f);var p=JSON.stringify(n);if(!(o=f.get(p))){f.set(p,o=Ht(Ct(c,l)));var h=function(){f.delete(p),f.size||u.delete(s),d.unsubscribe()},d=o.subscribe({next:h,error:h,complete:h})}}else o=Ht(Ct(c,l))}else o=Vt.of({data:{}}),t=this.prepareContext(t);var v=this.transform(e).clientQuery;return v&&(o=function(e,t){return new Vt((function(n){var r=n.next,i=n.error,o=n.complete,a=0,s=!1,u={next:function(e){++a,new Promise((function(n){n(t(e))})).then((function(e){--a,r&&r.call(n,e),s&&u.complete()}),(function(e){--a,i&&i.call(n,e)}))},error:function(e){i&&i.call(n,e)},complete:function(){s=!0,a||o&&o.call(n)}},c=e.subscribe(u);return function(){return c.unsubscribe()}}))}(o,(function(e){return a.localState.runResolvers({document:v,remoteResult:e,context:t,variables:n})}))),o},e.prototype.fetchRequest=function(e){var t,n,r=this,i=e.requestId,o=e.queryId,a=e.document,s=e.options,u=e.fetchMoreForQueryId,c=s.variables,l=s.errorPolicy,f=void 0===l?"none":l,p=s.fetchPolicy;return new Promise((function(e,l){var h=r.getObservableFromLink(a,s.context,c),d="fetchRequest:"+o;r.fetchQueryRejectFns.set(d,l);var v=function(){r.fetchQueryRejectFns.delete(d),r.setQuery(o,(function(e){e.subscriptions.delete(y)}))},y=h.map((function(e){if(i>=r.getQuery(o).lastRequestId&&(r.markQueryResult(o,e,s,u),r.queryStore.markQueryResult(o,e,u),r.invalidate(o),r.invalidate(u),r.broadcastQueries()),"none"===f&&Lt(e.errors))return l(new Bt({graphQLErrors:e.errors}));if("all"===f&&(n=e.errors),u||"no-cache"===p)t=e.data;else{var h=r.dataStore.getCache().diff({variables:c,query:a,optimistic:!1,returnPartialData:!0}),d=h.result;(h.complete||s.returnPartialData)&&(t=d)}})).subscribe({error:function(e){v(),l(e)},complete:function(){v(),e({data:t,errors:n,loading:!1,networkStatus:Qt.ready,stale:!1})}});r.setQuery(o,(function(e){e.subscriptions.add(y)}))}))},e.prototype.getQuery=function(e){return this.queries.get(e)||{listeners:new Set,invalidated:!1,document:null,newData:null,lastRequestId:1,observableQuery:null,subscriptions:new Set}},e.prototype.setQuery=function(e,t){var n=this.getQuery(e),i=r(r({},n),t(n));this.queries.set(e,i)},e.prototype.invalidate=function(e,t){void 0===t&&(t=!0),e&&this.setQuery(e,(function(){return{invalidated:t}}))},e.prototype.prepareContext=function(e){void 0===e&&(e={});var t=this.localState.prepareContext(e);return r(r({},t),{clientAwareness:this.clientAwareness})},e.prototype.checkInFlight=function(e){var t=this.queryStore.get(e);return t&&t.networkStatus!==Qt.ready&&t.networkStatus!==Qt.error},e.prototype.startPollingQuery=function(e,t,n){var i=this,o=e.pollInterval;if("production"===process.env.NODE_ENV?Oe(o,18):Oe(o,"Attempted to start a polling query without a polling interval."),!this.ssrMode){var a=this.pollingInfoByQueryId.get(t);a||this.pollingInfoByQueryId.set(t,a={}),a.interval=o,a.options=r(r({},e),{fetchPolicy:"network-only"});var s=function(){var e=i.pollingInfoByQueryId.get(t);e&&(i.checkInFlight(t)?u():i.fetchQuery(t,e.options,$t.poll).then(u,u))},u=function(){var e=i.pollingInfoByQueryId.get(t);e&&(clearTimeout(e.timeout),e.timeout=setTimeout(s,e.interval))};n&&this.addQueryListener(t,n),u()}return t},e.prototype.stopPollingQuery=function(e){this.pollingInfoByQueryId.delete(e)},e}(),en=function(){function e(e){this.cache=e}return e.prototype.getCache=function(){return this.cache},e.prototype.markQueryResult=function(e,t,n,r,i){void 0===i&&(i=!1);var o=!dt(e);i&&dt(e)&&e.data&&(o=!0),!r&&o&&this.cache.write({result:e.data,dataId:"ROOT_QUERY",query:t,variables:n})},e.prototype.markSubscriptionResult=function(e,t,n){dt(e)||this.cache.write({result:e.data,dataId:"ROOT_SUBSCRIPTION",query:t,variables:n})},e.prototype.markMutationInit=function(e){var t,n=this;e.optimisticResponse&&(t="function"==typeof e.optimisticResponse?e.optimisticResponse(e.variables):e.optimisticResponse,this.cache.recordOptimisticTransaction((function(r){var i=n.cache;n.cache=r;try{n.markMutationResult({mutationId:e.mutationId,result:{data:t},document:e.document,variables:e.variables,updateQueries:e.updateQueries,update:e.update})}finally{n.cache=i}}),e.mutationId))},e.prototype.markMutationResult=function(e){var t=this;if(!dt(e.result)){var n=[{result:e.result.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}],r=e.updateQueries;r&&Object.keys(r).forEach((function(i){var o=r[i],a=o.query,s=o.updater,u=t.cache.diff({query:a.document,variables:a.variables,returnPartialData:!0,optimistic:!1}),c=u.result;if(u.complete){var l=ht((function(){return s(c,{mutationResult:e.result,queryName:Je(a.document)||void 0,queryVariables:a.variables})}));l&&n.push({result:l,dataId:"ROOT_QUERY",query:a.document,variables:a.variables})}})),this.cache.performTransaction((function(t){n.forEach((function(e){return t.write(e)}));var r=e.update;r&&ht((function(){return r(t,e.result)}))}))}},e.prototype.markMutationComplete=function(e){var t=e.mutationId;e.optimisticResponse&&this.cache.removeOptimistic(t)},e.prototype.markUpdateQueryResult=function(e,t,n){this.cache.write({result:n,dataId:"ROOT_QUERY",variables:t,query:e})},e.prototype.reset=function(){return this.cache.reset()},e}(),tn=!1,nn=function(){function e(e){var t=this;this.defaultOptions={},this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var n=e.cache,r=e.ssrMode,i=void 0!==r&&r,o=e.ssrForceFetchDelay,a=void 0===o?0:o,s=e.connectToDevTools,u=e.queryDeduplication,c=void 0===u||u,l=e.defaultOptions,f=e.assumeImmutableResults,p=void 0!==f&&f,h=e.resolvers,d=e.typeDefs,v=e.fragmentMatcher,y=e.name,m=e.version,g=e.link;if(!g&&h&&(g=jt.empty()),!g||!n)throw"production"===process.env.NODE_ENV?new _e(1):new _e("In order to initialize Apollo Client, you must specify 'link' and 'cache' properties in the options object.\nThese options are part of the upgrade requirements when migrating from Apollo Client 1.x to Apollo Client 2.x.\nFor more information, please visit: https://www.apollographql.com/docs/tutorial/client.html#apollo-client-setup");this.link=g,this.cache=n,this.store=new en(n),this.disableNetworkFetches=i||a>0,this.queryDeduplication=c,this.defaultOptions=l||{},this.typeDefs=d,a&&setTimeout((function(){return t.disableNetworkFetches=!1}),a),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this);var b="production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&!window.__APOLLO_CLIENT__;(void 0===s?b:s&&"undefined"!=typeof window)&&(window.__APOLLO_CLIENT__=this),tn||"production"===process.env.NODE_ENV||(tn=!0,"undefined"!=typeof window&&window.document&&window.top===window.self&&void 0===window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("Chrome")>-1&&console.debug("Download the Apollo DevTools for a better development experience: https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm")),this.version="2.6.8",this.localState=new Jt({cache:n,client:this,resolvers:h,fragmentMatcher:v}),this.queryManager=new Zt({link:this.link,store:this.store,queryDeduplication:c,ssrMode:i,clientAwareness:{name:y,version:m},localState:this.localState,assumeImmutableResults:p,onBroadcast:function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.queryStore.getStore(),mutations:t.queryManager.mutationStore.getStore()},dataWithOptimisticResults:t.cache.extract(!0)})}})}return e.prototype.stop=function(){this.queryManager.stop()},e.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=r(r({},this.defaultOptions.watchQuery),e)),!this.disableNetworkFetches||"network-only"!==e.fetchPolicy&&"cache-and-network"!==e.fetchPolicy||(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},e.prototype.query=function(e){return this.defaultOptions.query&&(e=r(r({},this.defaultOptions.query),e)),"production"===process.env.NODE_ENV?Oe("cache-and-network"!==e.fetchPolicy,2):Oe("cache-and-network"!==e.fetchPolicy,"The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."),this.disableNetworkFetches&&"network-only"===e.fetchPolicy&&(e=r(r({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},e.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=r(r({},this.defaultOptions.mutate),e)),this.queryManager.mutate(e)},e.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.cache.readQuery(e,t)},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.cache.readFragment(e,t)},e.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return this.queryManager.broadcastQueries(),t},e.prototype.writeData=function(e){var t=this.cache.writeData(e);return this.queryManager.broadcastQueries(),t},e.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},e.prototype.__requestRaw=function(e){return Ct(this.link,e)},e.prototype.initQueryManager=function(){return"production"===process.env.NODE_ENV||Oe.warn("Calling the initQueryManager method is no longer necessary, and it will be removed from ApolloClient in version 3.0."),this.queryManager},e.prototype.resetStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.resetStoreCallbacks.map((function(e){return e()})))})).then((function(){return e.reFetchObservableQueries()}))},e.prototype.clearStore=function(){var e=this;return Promise.resolve().then((function(){return e.queryManager.clearStore()})).then((function(){return Promise.all(e.clearStoreCallbacks.map((function(e){return e()})))}))},e.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter((function(t){return t!==e}))}},e.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},e.prototype.extract=function(e){return this.cache.extract(e)},e.prototype.restore=function(e){return this.cache.restore(e)},e.prototype.addResolvers=function(e){this.localState.addResolvers(e)},e.prototype.setResolvers=function(e){this.localState.setResolvers(e)},e.prototype.getResolvers=function(){return this.localState.getResolvers()},e.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},e}();function rn(e){return{kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(e)}]}}function on(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return null;if(Array.isArray(e))return on(e[0]);var t=[];return Object.keys(e).forEach((function(n){var r={kind:"Field",name:{kind:"Name",value:n},selectionSet:on(e[n])||void 0};t.push(r)})),{kind:"SelectionSet",selections:t}}var an={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:null,variableDefinitions:null,directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:null,name:{kind:"Name",value:"__typename"},arguments:[],directives:[],selectionSet:null}]}}]},sn=function(){function e(){}return e.prototype.transformDocument=function(e){return e},e.prototype.transformForLink=function(e){return e},e.prototype.readQuery=function(e,t){return void 0===t&&(t=!1),this.read({query:e.query,variables:e.variables,optimistic:t})},e.prototype.readFragment=function(e,t){return void 0===t&&(t=!1),this.read({query:ze(e.fragment,e.fragmentName),variables:e.variables,rootId:e.id,optimistic:t})},e.prototype.writeQuery=function(e){this.write({dataId:"ROOT_QUERY",result:e.data,query:e.query,variables:e.variables})},e.prototype.writeFragment=function(e){this.write({dataId:e.id,result:e.data,variables:e.variables,query:ze(e.fragment,e.fragmentName)})},e.prototype.writeData=function(e){var t,n,r=e.id,i=e.data;if(void 0!==r){var o=null;try{o=this.read({rootId:r,optimistic:!1,query:an})}catch(e){}var a=o&&o.__typename||"__ClientData",s=Object.assign({__typename:a},i);this.writeFragment({id:r,fragment:(t=s,n=a,{kind:"Document",definitions:[{kind:"FragmentDefinition",typeCondition:{kind:"NamedType",name:{kind:"Name",value:n||"__FakeType"}},name:{kind:"Name",value:"GeneratedClientQuery"},selectionSet:on(t)}]}),data:s})}else this.writeQuery({query:rn(i),data:i})},e}(),un=null,cn={},ln=1,fn=Array,pn=fn["@wry/context:Slot"]||function(){var e=function(){function e(){this.id=["slot",ln++,Date.now(),Math.random().toString(36).slice(2)].join(":")}return e.prototype.hasValue=function(){for(var e=un;e;e=e.parent)if(this.id in e.slots){var t=e.slots[this.id];if(t===cn)break;return e!==un&&(un.slots[this.id]=t),!0}return un&&(un.slots[this.id]=cn),!1},e.prototype.getValue=function(){if(this.hasValue())return un.slots[this.id]},e.prototype.withValue=function(e,t,n,r){var i,o=((i={__proto__:null})[this.id]=e,i),a=un;un={parent:a,slots:o};try{return t.apply(r,n)}finally{un=a}},e.bind=function(e){var t=un;return function(){var n=un;try{return un=t,e.apply(this,arguments)}finally{un=n}}},e.noContext=function(e,t,n){if(!un)return e.apply(n,t);var r=un;try{return un=null,e.apply(n,t)}finally{un=r}},e}();try{Object.defineProperty(fn,"@wry/context:Slot",{value:fn["@wry/context:Slot"]=e,enumerable:!1,writable:!1,configurable:!1})}finally{return e}}();pn.bind,pn.noContext;function hn(){}var dn=function(){function e(e,t){void 0===e&&(e=1/0),void 0===t&&(t=hn),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return e.prototype.has=function(e){return this.map.has(e)},e.prototype.get=function(e){var t=this.getEntry(e);return t&&t.value},e.prototype.getEntry=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var n=t.older,r=t.newer;r&&(r.older=n),n&&(n.newer=r),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=r)}return t},e.prototype.set=function(e,t){var n=this.getEntry(e);return n?n.value=t:(n={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=n),this.newest=n,this.oldest=this.oldest||n,this.map.set(e,n),n.value)},e.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},e.prototype.delete=function(e){var t=this.map.get(e);return!!t&&(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0)},e}(),vn=new pn,yn=[],mn=[];function gn(e,t){if(!e)throw new Error(t||"assertion failure")}function bn(e){switch(e.length){case 0:throw new Error("unknown value");case 1:return e[0];case 2:throw e[1]}}var En=function(){function e(t,n){this.fn=t,this.args=n,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],++e.count}return e.prototype.recompute=function(){if(gn(!this.recomputing,"already recomputing"),function(e){var t=vn.getValue();if(t)return e.parents.add(t),t.childValues.has(e)||t.childValues.set(e,[]),_n(e)?Nn(t,e):Sn(t,e),t}(this)||!In(this))return _n(this)?function(e){var t=xn(e);vn.withValue(e,wn,[e]),function(e){if("function"==typeof e.subscribe)try{An(e),e.unsubscribe=e.subscribe.apply(null,e.args)}catch(t){return e.setDirty(),!1}return!0}(e)&&function(e){if(e.dirty=!1,_n(e))return;kn(e)}(e);return t.forEach(In),bn(e.value)}(this):bn(this.value)},e.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,On(this),An(this))},e.prototype.dispose=function(){var e=this;xn(this).forEach(In),An(this),this.parents.forEach((function(t){t.setDirty(),Dn(t,e)}))},e.count=0,e}();function wn(e){e.recomputing=!0,e.value.length=0;try{e.value[0]=e.fn.apply(null,e.args)}catch(t){e.value[1]=t}e.recomputing=!1}function _n(e){return e.dirty||!(!e.dirtyChildren||!e.dirtyChildren.size)}function On(e){e.parents.forEach((function(t){return Nn(t,e)}))}function kn(e){e.parents.forEach((function(t){return Sn(t,e)}))}function Nn(e,t){if(gn(e.childValues.has(t)),gn(_n(t)),e.dirtyChildren){if(e.dirtyChildren.has(t))return}else e.dirtyChildren=mn.pop()||new Set;e.dirtyChildren.add(t),On(e)}function Sn(e,t){gn(e.childValues.has(t)),gn(!_n(t));var n,r,i,o=e.childValues.get(t);0===o.length?e.childValues.set(t,t.value.slice(0)):(n=o,r=t.value,(i=n.length)>0&&i===r.length&&n[i-1]===r[i-1]||e.setDirty()),Tn(e,t),_n(e)||kn(e)}function Tn(e,t){var n=e.dirtyChildren;n&&(n.delete(t),0===n.size&&(mn.length<100&&mn.push(n),e.dirtyChildren=null))}function In(e){return 0===e.parents.size&&"function"==typeof e.reportOrphan&&!0===e.reportOrphan()}function xn(e){var t=yn;return e.childValues.size>0&&(t=[],e.childValues.forEach((function(n,r){Dn(e,r),t.push(r)}))),gn(null===e.dirtyChildren),t}function Dn(e,t){t.parents.delete(e),e.childValues.delete(t),Tn(e,t)}function An(e){var t=e.unsubscribe;"function"==typeof t&&(e.unsubscribe=void 0,t())}var Rn=function(){function e(e){this.weakness=e}return e.prototype.lookup=function(){for(var e=[],t=0;t0;return d&&!s&&h.missing.forEach((function(e){if(!e.tolerable)throw"production"===process.env.NODE_ENV?new _e(8):new _e("Can't find field "+e.fieldName+" on object "+JSON.stringify(e.object,null,2)+".")})),o&&De(o,h.result)&&(h.result=o),{result:h.result,complete:!d}},e.prototype.executeStoreQuery=function(e){var t=e.query,n=e.rootValue,r=e.contextValue,i=e.variableValues,o=e.fragmentMatcher,a=void 0===o?Gn:o,s=Xe(t),u={query:t,fragmentMap:Ze(He(t)),contextValue:r,variableValues:i,fragmentMatcher:a};return this.executeSelectionSet({selectionSet:s.selectionSet,rootValue:n,execContext:u})},e.prototype.executeSelectionSet=function(e){var t=this,n=e.selectionSet,i=e.rootValue,o=e.execContext,a=o.fragmentMap,s=o.contextValue,u=o.variableValues,c={result:null},l=[],f=s.store.get(i.id),p=f&&f.__typename||"ROOT_QUERY"===i.id&&"Query"||void 0;function h(e){var t;return e.missing&&(c.missing=c.missing||[],(t=c.missing).push.apply(t,e.missing)),e.result}return n.selections.forEach((function(e){var n;if($e(e,u))if(Qe(e)){var c=h(t.executeField(f,p,e,o));void 0!==c&&l.push(((n={})[Ce(e)]=c,n))}else{var d=void 0;if(qe(e))d=e;else if(!(d=a[e.name.value]))throw"production"===process.env.NODE_ENV?new _e(9):new _e("No fragment named "+e.name.value);var v=d.typeCondition&&d.typeCondition.name.value,y=!v||o.fragmentMatcher(i,v,s);if(y){var m=t.executeSelectionSet({selectionSet:d.selectionSet,rootValue:i,execContext:o});"heuristic"===y&&m.missing&&(m=r(r({},m),{missing:m.missing.map((function(e){return r(r({},e),{tolerable:!0})}))})),l.push(h(m))}}})),c.result=gt(l),this.freezeResults&&"production"!==process.env.NODE_ENV&&Object.freeze(c.result),c},e.prototype.executeField=function(e,t,n,r){var i=r.variableValues,o=r.contextValue,a=function(e,t,n,r,i,o){o.resultKey;var a=o.directives,s=n;(r||a)&&(s=Fe(s,r,a));var u=void 0;if(e&&void 0===(u=e[s])&&i.cacheRedirects&&"string"==typeof t){var c=i.cacheRedirects[t];if(c){var l=c[n];l&&(u=l(e,r,{getCacheKey:function(e){var t=i.dataIdFromObject(e);return t&&Ve({id:t,typename:e.__typename})}}))}}if(void 0===u)return{result:u,missing:[{object:e,fieldName:s,tolerable:!1}]};f=u,null!=f&&"object"==typeof f&&"json"===f.type&&(u=u.json);var f;return{result:u}}(e,t,n.name.value,je(n,i),o,{resultKey:Ce(n),directives:Le(n,i)});return Array.isArray(a.result)?this.combineExecResults(a,this.executeSubSelectedArray({field:n,array:a.result,execContext:r})):n.selectionSet?null==a.result?a:this.combineExecResults(a,this.executeSelectionSet({selectionSet:n.selectionSet,rootValue:a.result,execContext:r})):(Un(n,a.result),this.freezeResults&&"production"!==process.env.NODE_ENV&&vt(a),a)},e.prototype.combineExecResults=function(){for(var e,t=[],n=0;n=0)return!0;n[e].push(t)}else n[e]=[t];return!1}var Hn={fragmentMatcher:new Pn,dataIdFromObject:function(e){if(e.__typename){if(void 0!==e.id)return e.__typename+":"+e.id;if(void 0!==e._id)return e.__typename+":"+e._id}return null},addTypename:!0,resultCaching:!0,freezeResults:!1};var Xn=Object.prototype.hasOwnProperty,Zn=function(e){function t(t,n,r){var i=e.call(this,Object.create(null))||this;return i.optimisticId=t,i.parent=n,i.transaction=r,i}return n(t,e),t.prototype.toObject=function(){return r(r({},this.parent.toObject()),this.data)},t.prototype.get=function(e){return Xn.call(this.data,e)?this.data[e]:this.parent.get(e)},t}(zn),er=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;n.watches=new Set,n.typenameDocumentCache=new Map,n.cacheKeyRoot=new Rn(ut),n.silenceBroadcast=!1,n.config=r(r({},Hn),t),n.config.customResolvers&&("production"===process.env.NODE_ENV||Oe.warn("customResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating customResolvers in the next major version."),n.config.cacheRedirects=n.config.customResolvers),n.config.cacheResolvers&&("production"===process.env.NODE_ENV||Oe.warn("cacheResolvers have been renamed to cacheRedirects. Please update your config as we will be deprecating cacheResolvers in the next major version."),n.config.cacheRedirects=n.config.cacheResolvers),n.addTypename=!!n.config.addTypename,n.data=n.config.resultCaching?new Ln:new zn,n.optimisticData=n.data,n.storeWriter=new Yn,n.storeReader=new Bn({cacheKeyRoot:n.cacheKeyRoot,freezeResults:t.freezeResults});var i=n,o=i.maybeBroadcastWatch;return n.maybeBroadcastWatch=Cn((function(e){return o.call(n,e)}),{makeCacheKey:function(e){if(!e.optimistic&&!e.previousResult)return i.data instanceof Ln?i.cacheKeyRoot.lookup(e.query,JSON.stringify(e.variables)):void 0}}),n}return n(t,e),t.prototype.restore=function(e){return e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).toObject()},t.prototype.read=function(e){if("string"==typeof e.rootId&&void 0===this.data.get(e.rootId))return null;var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.readQueryFromStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,rootId:e.rootId,fragmentMatcherFunction:n,previousResult:e.previousResult,config:this.config})||null},t.prototype.write=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;this.storeWriter.writeResultToStore({dataId:e.dataId,result:e.result,variables:e.variables,document:this.transformDocument(e.query),store:this.data,dataIdFromObject:this.config.dataIdFromObject,fragmentMatcherFunction:n}),this.broadcastWatches()},t.prototype.diff=function(e){var t=this.config.fragmentMatcher,n=t&&t.match;return this.storeReader.diffQueryAgainstStore({store:e.optimistic?this.optimisticData:this.data,query:this.transformDocument(e.query),variables:e.variables,returnPartialData:e.returnPartialData,previousResult:e.previousResult,fragmentMatcherFunction:n,config:this.config})},t.prototype.watch=function(e){var t=this;return this.watches.add(e),function(){t.watches.delete(e)}},t.prototype.evict=function(e){throw"production"===process.env.NODE_ENV?new _e(1):new _e("eviction is not implemented on InMemory Cache")},t.prototype.reset=function(){return this.data.clear(),this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){for(var t=[],n=0,r=this.optimisticData;r instanceof Zn;)r.optimisticId===e?++n:t.push(r),r=r.parent;if(n>0){for(this.optimisticData=r;t.length>0;){var i=t.pop();this.performTransaction(i.transaction,i.optimisticId)}this.broadcastWatches()}},t.prototype.performTransaction=function(e,t){var n=this.data,r=this.silenceBroadcast;this.silenceBroadcast=!0,"string"==typeof t&&(this.data=this.optimisticData=new Zn(t,this.optimisticData,e));try{e(this)}finally{this.silenceBroadcast=r,this.data=n}this.broadcastWatches()},t.prototype.recordOptimisticTransaction=function(e,t){return this.performTransaction(e,t)},t.prototype.transformDocument=function(e){if(this.addTypename){var t=this.typenameDocumentCache.get(e);return t||(t=B(Ye(e),{SelectionSet:{enter:function(e,t,n){if(!n||"OperationDefinition"!==n.kind){var i=e.selections;if(i&&!i.some((function(e){return Qe(e)&&("__typename"===e.name.value||0===e.name.value.lastIndexOf("__",0))}))){var o=n;if(!(Qe(o)&&o.directives&&o.directives.some((function(e){return"export"===e.name.value}))))return r(r({},e),{selections:a(i,[nt])})}}}}}),this.typenameDocumentCache.set(e,t),this.typenameDocumentCache.set(t,t)),t}return e},t.prototype.broadcastWatches=function(){var e=this;this.silenceBroadcast||this.watches.forEach((function(t){return e.maybeBroadcastWatch(t)}))},t.prototype.maybeBroadcastWatch=function(e){e.callback(this.diff({query:e.query,variables:e.variables,previousResult:e.previousResult&&e.previousResult(),optimistic:e.optimistic}))},t}(sn),tr={http:{includeQuery:!0,includeExtensions:!1},headers:{accept:"*/*","content-type":"application/json"},options:{method:"POST"}},nr=function(e,t,n){var r=new Error(n);throw r.name="ServerError",r.response=e,r.statusCode=e.status,r.result=t,r},rr=function(e,t){var n;try{n=JSON.stringify(e)}catch(e){var r="production"===process.env.NODE_ENV?new _e(2):new _e("Network request failed. "+t+" is not serializable: "+e.message);throw r.parseError=e,r}return n},ir=function(e){void 0===e&&(e={});var t=e.uri,n=void 0===t?"/graphql":t,i=e.fetch,o=e.includeExtensions,a=e.useGETForQueries,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=300&&nr(e,t,"Response not successful: Received status code "+e.status),Array.isArray(t)||t.hasOwnProperty("data")||t.hasOwnProperty("errors")||nr(e,t,"Server response was missing for query '"+(Array.isArray(r)?r.map((function(e){return e.operationName})):r.operationName)+"'."),t}))})).then((function(e){return n.next(e),n.complete(),e})).catch((function(e){"AbortError"!==e.name&&(e.result&&e.result.errors&&e.result.data&&n.next(e.result),n.error(e))})),function(){p&&p.abort()}}))}))};var or,ar,sr=function(e){function t(t){return e.call(this,ir(t).request)||this}return n(t,e),t}(jt);(or=e.ConnectionMode||(e.ConnectionMode={}))[or.AUTO=0]="AUTO",or[or.PLAIN=1]="PLAIN",or[or.NODES=2]="NODES",or[or.EDGES=3]="EDGES",or[or.ITEMS=4]="ITEMS",(ar=e.ArgumentMode||(e.ArgumentMode={}))[ar.TYPE=0]="TYPE",ar[ar.LIST=1]="LIST";var ur,cr=function(){function t(){}return t.transformOutgoingData=function(e,t,n,r,i,o,a,s){var u=this,c=_r.getInstance(),l=e.getRelations(),f={};return void 0===a&&(a=new Map),void 0===s&&(s=!1),Object.keys(t).forEach((function(p){var h=t[p],d=e.getRelations().has(p);if(!(h instanceof Array?d&&u.isRecursion(a,h[0]):d&&u.isRecursion(a,h))&&u.shouldIncludeOutgoingField(s&&n,p,h,e,r,i,o)){var v=be.getRelatedModel(l.get(p));if(h instanceof Array){var y=c.getModel(se(p),!0);y?(u.addRecordForRecursionDetection(a,h[0]),f[p]=h.map((function(t){return u.transformOutgoingData(y||e,t,n,r,i,void 0,a,!0)}))):f[p]=h}else"object"==typeof h&&void 0!==h.$id?(v||(v=c.getModel(h.$self().entity)),u.addRecordForRecursionDetection(a,h),f[p]=u.transformOutgoingData(v,h,n,r,i,void 0,a,!0)):f[p]=h}})),f},t.transformIncomingData=function(t,n,r,i){var o=this;void 0===r&&(r=!1),void 0===i&&(i=!1);var a={},s=_r.getInstance();return i||(s.logger.group("Transforming incoming data"),s.logger.log("Raw data:",t)),Array.isArray(t)?a=t.map((function(e){return o.transformIncomingData(e,n,r,!0)})):Object.keys(t).forEach((function(u){if(void 0!==t[u]&&null!==t[u]&&u in t)if(he(t[u])){var c=s.getModel(u,!0)||n;if(t[u].nodes&&s.connectionMode===e.ConnectionMode.NODES)a[ae(u)]=o.transformIncomingData(t[u].nodes,c,r,!0);else if(t[u].edges&&s.connectionMode===e.ConnectionMode.EDGES)a[ae(u)]=o.transformIncomingData(t[u].edges,c,r,!0);else if(t.node&&s.connectionMode===e.ConnectionMode.EDGES)a=o.transformIncomingData(t.node,c,r,!0);else if(t[u].items&&s.connectionMode===e.ConnectionMode.ITEMS)a[ae(u)]=o.transformIncomingData(t[u].items,c,r,!0);else{var l=u;r&&!i&&(l=ce(l=t[u].nodes?c.pluralName:c.singularName)),a[l]=o.transformIncomingData(t[u],c,r,!0)}}else be.isFieldNumber(n.fields.get(u))?a[u]=parseFloat(t[u]):u.endsWith("Type")&&n.isTypeFieldOfPolymorphicRelation(u)?a[u]=ae(ce(t[u])):a[u]=t[u]})),i?a.$isPersisted=!0:(s.logger.log("Transformed data:",a),s.logger.groupEnd()),ye(a)},t.shouldIncludeOutgoingField=function(e,t,n,r,i,o,a){if(a&&a.includes(t))return!0;if(t.startsWith("$"))return!1;if("pivot"===t)return!1;if(null==n)return!1;if(!this.inputTypeContainsField(r,t,i,o))return!1;if(r.getRelations().has(t)){if(e)return!1;var s=r.getRelations().get(t),u=be.getRelatedModel(s);return!(!u||!r.shouldEagerSaveRelation(t,s,u))}return!0},t.inputTypeContainsField=function(e,t,n,r){var i=_r.getInstance(),o=i.adapter.getInputTypeName(e,n,r),a=i.schema.getType(o,!1);if(null===a)throw new Error("Type "+a+" doesn't exist.");return void 0!==a.inputFields.find((function(e){return e.name===t}))},t.addRecordForRecursionDetection=function(e,t){var n=_r.getInstance();if(t)if(t.$self){var r=n.getModel(t.$self().entity),i=e.get(r.singularName)||[];i.push(t.$id),e.set(r.singularName,i)}else n.logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that.");else n.logger.warn("Trying to add invalid record",t,"to recursion detection")},t.isRecursion=function(e,t){if(!t)return!1;if(!t.$self)return _r.getInstance().logger.warn("Seems like you're using non-model classes with plugin graphql. You shouldn't do that."),!1;var n=_r.getInstance().getModel(t.$self().entity);return(e.get(n.singularName)||[]).includes(t.$id)},t}(),lr=((ur=V)&&ur.default||ur).parse;function fr(e){return e.replace(/[\s,]+/g," ").trim()}var pr={},hr={};var dr=!0;var vr=!1;function yr(e){var t=fr(e);if(pr[t])return pr[t];var n=lr(e,{experimentalFragmentVariables:vr});if(!n||"Document"!==n.kind)throw new Error("Not a valid GraphQL document.");return n=function e(t,n){var r=Object.prototype.toString.call(t);if("[object Array]"===r)return t.map((function(t){return e(t,n)}));if("[object Object]"!==r)throw new Error("Unexpected input.");n&&t.loc&&delete t.loc,t.loc&&(delete t.loc.startToken,delete t.loc.endToken);var i,o,a,s=Object.keys(t);for(i in s)s.hasOwnProperty(i)&&(o=t[s[i]],"[object Object]"!==(a=Object.prototype.toString.call(o))&&"[object Array]"!==a||(t[s[i]]=e(o,!0)));return t}(n=function(e){for(var t,n={},r=[],i=0;i5:t.includes(s.singularName);if(e.shouldEagerLoadRelation(a,o,s)&&!c){var l=t.slice(0);l.push(s.singularName),i.push(r.buildField(s,n,be.isConnection(o),void 0,l,a,!1))}})),i.join("\n")},t.prepareArguments=function(t){return t=t?ye(t):{},Object.keys(t).forEach((function(n){var r=t[n];r&&he(r)&&(_r.getInstance().adapter.getArgumentMode()===e.ArgumentMode.LIST?(Object.keys(r).forEach((function(e){t[e]=r[e]})),delete t[n]):t[n]={__type:ue(n)})})),t},t}(),kr=function(){function e(){}return e.insertData=function(e,t){return i(this,void 0,void 0,(function(){var n,r=this;return o(this,(function(a){switch(a.label){case 0:return n={},[4,Promise.all(Object.keys(e).map((function(a){return i(r,void 0,void 0,(function(){var r,i;return o(this,(function(o){switch(o.label){case 0:return r=e[a],_r.getInstance().logger.log("Inserting records",r),[4,t("insertOrUpdate",{data:r})];case 1:return i=o.sent(),Object.keys(i).forEach((function(e){n[e]||(n[e]=[]),n[e]=n[e].concat(i[e])})),[2]}}))}))})))];case 1:return a.sent(),[2,n]}}))}))},e}(),Nr=function(){function e(){}return e.mutation=function(e,t,n,r,a){return i(this,void 0,void 0,(function(){var i,s,u,c,l,f,p,h,d;return o(this,(function(o){switch(o.label){case 0:return t?[4,(i=_r.getInstance()).loadSchema()]:[3,5];case 1:return s=o.sent(),u=Er.returnsConnection(s.getMutation(e)),c=Or.buildQuery("mutation",r,a,e,t,u),[4,i.apollo.request(r,c,t,!0)];case 2:return l=o.sent(),e===i.adapter.getNameForDestroy(r)?[3,4]:((l=l[Object.keys(l)[0]]).id=me(l.id),[4,kr.insertData((d={},d[r.pluralName]=l,d),n)]);case 3:return f=o.sent(),p=f[r.pluralName],(h=p[p.length-1])?[2,h]:(_r.getInstance().logger.log("Couldn't find the record of type '",r.pluralName,"' within",f,". Falling back to find()"),[2,r.baseModel.query().last()]);case 4:return[2,!0];case 5:return[2]}}))}))},e.getModelFromState=function(e){return _r.getInstance().getModel(e.$name)},e.prepareArgs=function(e,t){return e=e||{},t&&(e.id=t),e},e.addRecordToArgs=function(e,t,n,r,i){return e[t.singularName]=cr.transformOutgoingData(t,n,!1,r,i),e},e.transformArgs=function(e,t){var n=_r.getInstance();return Object.keys(e).forEach((function(r){var i=e[r];if(i instanceof n.components.Model){var o=n.getModel(se(i.$self().entity)),a=cr.transformOutgoingData(o,i,!1,t,"");n.logger.log("A",r,"model was found within the variables and will be transformed from",i,"to",a),e[r]=a}})),e},e}(),Sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.destroy=t.call.bind(t),n.$destroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.$dispatch("destroy",{id:me(this.$id)})]}))}))},n.$deleteAndDestroy=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.$delete()];case 1:return e.sent(),[2,this.$destroy()]}}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForDestroy(e),i="destroy",(u=e.$mockHook("destroy",{id:a}))?[4,kr.insertData(u,r)]:[3,2]):[3,4];case 1:return o.sent(),[2,!0];case 2:return s=this.prepareArgs(s,a),[4,Nr.mutation(t,s,r,e,i)];case 3:return o.sent(),[2,!0];case 4:throw new Error("The destroy action requires the 'id' to be set")}}))}))},t}(Nr),Tr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model;e.components.Actions.fetch=t.call.bind(t),n.fetch=function(e,t){return void 0===t&&(t=!1),i(this,void 0,void 0,(function(){var n;return o(this,(function(r){return he(n=e)||(n={id:e}),[2,this.dispatch("fetch",{filter:n,bypassCache:t})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch;return i(this,void 0,void 0,(function(){var e,i,a,s,u,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),i=this.getModelFromState(n),a="fetch",(s=i.$mockHook("fetch",{filter:t&&t.filter||{}}))?[2,kr.insertData(s,r)]:[4,e.loadSchema()];case 1:return o.sent(),u={},t&&t.filter&&(u=cr.transformOutgoingData(i,t.filter,!0,a,"",Object.keys(t.filter))),c=t&&t.bypassCache,l=!u.id,f=e.adapter.getNameForFetch(i,l),p=Or.buildQuery("query",i,a,f,u,l,l),[4,e.apollo.request(i,p,u,!1,c)];case 2:return h=o.sent(),[2,kr.insertData(h,r)]}}))}))},t}(Nr),Ir=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.mutate=t.call.bind(t),n.mutate=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.dispatch("mutate",e)]}))}))},r.$mutate=function(e){var t=e.name,n=e.args,r=e.multiple;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("mutate",{name:t,args:n,multiple:r})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.args,s=t.name;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return s?(e=_r.getInstance(),t=this.getModelFromState(n),i="mutate",(u=t.$mockHook("mutate",{name:s,args:a||{}}))?[2,kr.insertData(u,r)]:[4,e.loadSchema()]):[3,2];case 1:return o.sent(),a=this.prepareArgs(a),this.transformArgs(a,i),[2,Nr.mutation(s,a,r,t,i)];case 2:throw new Error("The mutate action requires the mutation name ('mutation') to be set")}}))}))},t}(Nr),xr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.persist=t.call.bind(t),n.$persist=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("persist",{id:this.$id,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.id,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u,c,l,f;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPersist(e),i=e.getRecordWithId(a),u="persist",(c=e.$mockHook("persist",{id:me(a),args:s||{}}))?[4,kr.insertData(c,r)]:[3,3]):[3,7];case 1:return l=o.sent(),[4,this.deleteObsoleteRecord(e,l,i)];case 2:return o.sent(),[2,l];case 3:return[4,_r.getInstance().loadSchema()];case 4:return o.sent(),s=this.prepareArgs(s),this.addRecordToArgs(s,e,i,u,t),[4,Nr.mutation(t,s,r,e,u)];case 5:return f=o.sent(),[4,this.deleteObsoleteRecord(e,f,i)];case 6:return o.sent(),[2,f];case 7:throw new Error("The persist action requires the 'id' to be set")}}))}))},t.deleteObsoleteRecord=function(e,t,n){return i(this,void 0,void 0,(function(){return o(this,(function(e){return t&&n&&t.id!==n.id?(_r.getInstance().logger.log("Dropping deprecated record",n),[2,n.$delete()]):[2,null]}))}))},t}(Nr),Dr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model.prototype;e.components.Actions.push=t.call.bind(t),n.$push=function(e){return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.$dispatch("push",{data:this,args:e})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.data,s=t.args;return i(this,void 0,void 0,(function(){var e,t,i,u;return o(this,(function(o){switch(o.label){case 0:return a?(e=this.getModelFromState(n),t=_r.getInstance().adapter.getNameForPush(e),i="push",(u=e.$mockHook("push",{data:a,args:s||{}}))?[2,kr.insertData(u,r)]:[4,_r.getInstance().loadSchema()]):[3,2];case 1:return o.sent(),s=this.prepareArgs(s,a.id),this.addRecordToArgs(s,e,a,i,t),[2,Nr.mutation(t,s,r,e,i)];case 2:throw new Error("The persist action requires the 'data' to be set")}}))}))},t}(Nr),Ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){var e=_r.getInstance(),n=e.components.Model,r=e.components.Model.prototype;e.components.Actions.query=t.call.bind(t),n.customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,this.dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))},r.$customQuery=function(e){var t=e.name,n=e.filter,r=e.multiple,a=e.bypassCache;return i(this,void 0,void 0,(function(){return o(this,(function(e){return(n=n||{}).id||(n.id=me(this.$id)),[2,this.$dispatch("query",{name:t,filter:n,multiple:r,bypassCache:a})]}))}))}},t.call=function(e,t){var n=e.state,r=e.dispatch,a=t.name,s=t.filter,u=t.bypassCache;return i(this,void 0,void 0,(function(){var e,t,i,c,l,f,p,h;return o(this,(function(o){switch(o.label){case 0:return a?(e=_r.getInstance(),t=this.getModelFromState(n),i="query",(c=t.$mockHook("query",{name:a,filter:s||{}}))?[2,kr.insertData(c,r)]:[4,e.loadSchema()]):[3,3];case 1:return l=o.sent(),s=s?cr.transformOutgoingData(t,s,!0,i,""):{},f=Er.returnsConnection(l.getQuery(a)),p=Or.buildQuery("query",t,i,a,s,f,!1),[4,e.apollo.request(t,p,s,!1,u)];case 2:return h=o.sent(),[2,kr.insertData(h,r)];case 3:throw new Error("The customQuery action requires the query name ('name') to be set")}}))}))},t}(Nr),Rr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleQuery=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.bypassCache,a=t.variables;return i(this,void 0,void 0,(function(){var e,t,i,s;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleQuery",{name:t.definitions[0].name.value,variables:a}))?[2,i]:(a=this.prepareArgs(a),[4,e.apollo.simpleQuery(pe(t),a,r)])):[3,2];case 1:return s=o.sent(),[2,(u=ye(s.data),JSON.parse(JSON.stringify(u)))];case 2:throw new Error("The simpleQuery action requires the 'query' to be set")}var u}))}))},t}(Nr),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.setup=function(){_r.getInstance().components.RootActions.simpleMutation=t.call.bind(t)},t.call=function(e,t){e.dispatch;var n=t.query,r=t.variables;return i(this,void 0,void 0,(function(){var e,t,i;return o(this,(function(o){switch(o.label){case 0:return e=_r.getInstance(),n?(t=fe(n),(i=e.globalMockHook("simpleMutation",{name:t.definitions[0].name.value,variables:r}))?[2,i]:(r=this.prepareArgs(r),[4,e.apollo.simpleMutation(pe(t),r)])):[3,2];case 1:return[2,ye(o.sent().data)];case 2:throw new Error("The simpleMutation action requires the 'query' to be set")}}))}))},t}(Nr),Fr=function(){function e(t,n){_r.setup(t,n),e.setupActions()}return e.prototype.getContext=function(){return _r.getInstance()},e.setupActions=function(){Tr.setup(),xr.setup(),Dr.setup(),Sr.setup(),Ir.setup(),Ar.setup(),Rr.setup(),Mr.setup()},e}(),jr=function(){function e(){}return e.install=function(t,n){return e.instance=new Fr(t,n),e.instance},e}(),Cr=null;var Qr=function(){function e(e,t){this.action=e,this.options=t}return e.prototype.for=function(e){return this.modelClass=e,this},e.prototype.andReturn=function(e){return this.returnValue=e,this.installMock(),this},e.prototype.installMock=function(){"simpleQuery"===this.action||"simpleMutation"===this.action?Cr.addGlobalMock(this):Cr.getModel(this.modelClass.entity).$addMock(this)},e}();return e.DefaultAdapter=wr,e.Mock=Qr,e.clearORMStore=function(){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(!Cr)throw new Error("Please call setupTestUtils() before!");return[4,Cr.database.store.dispatch("entities/deleteAll")];case 1:return e.sent(),[2]}}))}))},e.default=jr,e.mock=function(e,t){if(!Cr)throw new Error("Please call setupTestUtils() before!");return new Qr(e,t)},e.setupTestUtils=function(e){if(!e.instance)throw new Error("Please call this function after setting up the store!");Cr=e.instance.getContext()},e}({}); diff --git a/src/actions/action.ts b/src/actions/action.ts index 2e4015d9..d8f03d9a 100644 --- a/src/actions/action.ts +++ b/src/actions/action.ts @@ -106,8 +106,21 @@ export default class Action { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {Arguments} */ - static addRecordToArgs(args: Arguments, model: Model, data: Data, action: string): Arguments { - args[model.singularName] = Transformer.transformOutgoingData(model, data, false, action); + static addRecordToArgs( + args: Arguments, + model: Model, + data: Data, + action: string, + mutationName: string + ): Arguments { + // console.log('addRecordToArgs') + args[model.singularName] = Transformer.transformOutgoingData( + model, + data, + false, + action, + mutationName + ); return args; } @@ -125,7 +138,7 @@ export default class Action { if (value instanceof context.components.Model) { const model = context.getModel(singularize(value.$self().entity)); - const transformedValue = Transformer.transformOutgoingData(model, value, false, action); + const transformedValue = Transformer.transformOutgoingData(model, value, false, action, ""); context.logger.log( "A", key, diff --git a/src/actions/fetch.ts b/src/actions/fetch.ts index da56a504..32f99dce 100644 --- a/src/actions/fetch.ts +++ b/src/actions/fetch.ts @@ -39,7 +39,7 @@ export default class Fetch extends Action { ): Promise { const context = Context.getInstance(); const model = this.getModelFromState(state!); - const action = 'fetch' + const action = "fetch"; const mockReturnValue = model.$mockHook("fetch", { filter: params ? params.filter || {} : {} @@ -60,6 +60,7 @@ export default class Fetch extends Action { params.filter as Data, true, action, + "", Object.keys(params.filter) ); } diff --git a/src/actions/persist.ts b/src/actions/persist.ts index 58039095..8bcba6df 100644 --- a/src/actions/persist.ts +++ b/src/actions/persist.ts @@ -37,7 +37,7 @@ export default class Persist extends Action { const model = this.getModelFromState(state!); const mutationName = Context.getInstance().adapter.getNameForPersist(model); const oldRecord = model.getRecordWithId(id)!; - const action = 'persist' + const action = "persist"; const mockReturnValue = model.$mockHook("persist", { id: toNumber(id), @@ -53,7 +53,8 @@ export default class Persist extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args); - this.addRecordToArgs(args, model, oldRecord, action); + // console.log('mutationName: ' + mutationName) + this.addRecordToArgs(args, model, oldRecord, action, mutationName); // Send mutation const newRecord = await Action.mutation(mutationName, args as Data, dispatch!, model, action); diff --git a/src/actions/push.ts b/src/actions/push.ts index 206c98bf..14556a0d 100644 --- a/src/actions/push.ts +++ b/src/actions/push.ts @@ -35,7 +35,7 @@ export default class Push extends Action { if (data) { const model = this.getModelFromState(state!); const mutationName = Context.getInstance().adapter.getNameForPush(model); - const action = 'push' + const action = "push"; const mockReturnValue = model.$mockHook("push", { data, @@ -49,7 +49,7 @@ export default class Push extends Action { // Arguments await Context.getInstance().loadSchema(); args = this.prepareArgs(args, data.id); - this.addRecordToArgs(args, model, data, action); + this.addRecordToArgs(args, model, data, action, mutationName); // Send the mutation return Action.mutation(mutationName, args as Data, dispatch!, model, action); diff --git a/src/actions/query.ts b/src/actions/query.ts index de8d9373..ab461dd7 100644 --- a/src/actions/query.ts +++ b/src/actions/query.ts @@ -50,7 +50,7 @@ export default class Query extends Action { if (name) { const context: Context = Context.getInstance(); const model = this.getModelFromState(state!); - const action = 'query' + const action = "query"; const mockReturnValue = model.$mockHook("query", { name, @@ -64,7 +64,9 @@ export default class Query extends Action { const schema: Schema = await context.loadSchema(); // Filter - filter = filter ? Transformer.transformOutgoingData(model, filter as Data, true, action) : {}; + filter = filter + ? Transformer.transformOutgoingData(model, filter as Data, true, action, "") + : {}; // Multiple? const multiple: boolean = Schema.returnsConnection(schema.getQuery(name)!); diff --git a/src/adapters/adapter.ts b/src/adapters/adapter.ts index 851c2e86..8e555a9c 100644 --- a/src/adapters/adapter.ts +++ b/src/adapters/adapter.ts @@ -27,7 +27,7 @@ export default interface Adapter { getArgumentMode(): ArgumentMode; getFilterTypeName(model: Model): string; - getInputTypeName(model: Model, action?: string): string; + getInputTypeName(model: Model, action?: string, mutation?: string): string; prepareSchemaTypeName(name: string): string; } diff --git a/src/adapters/builtin/default-adapter.ts b/src/adapters/builtin/default-adapter.ts index 2031b879..6ca6bdf3 100644 --- a/src/adapters/builtin/default-adapter.ts +++ b/src/adapters/builtin/default-adapter.ts @@ -23,7 +23,7 @@ export default class DefaultAdapter implements Adapter { return `${upcaseFirstLetter(model.singularName)}Filter`; } - getInputTypeName(model: Model, action?: string): string { + getInputTypeName(model: Model, action?: string, mutation?: string): string { return `${upcaseFirstLetter(model.singularName)}Input`; } diff --git a/src/graphql/query-builder.ts b/src/graphql/query-builder.ts index 70e381fb..e778f4f8 100644 --- a/src/graphql/query-builder.ts +++ b/src/graphql/query-builder.ts @@ -44,7 +44,15 @@ export default class QueryBuilder { name = name ? name : model.pluralName; const field = context.schema!.getMutation(name, true) || context.schema!.getQuery(name, true); - let params: string = this.buildArguments(model, action, args, false, filter, allowIdFields, field); + let params: string = this.buildArguments( + model, + action, + args, + false, + filter, + allowIdFields, + field + ); path = path.length === 0 ? [model.singularName] : path; const fields = ` @@ -217,7 +225,13 @@ export default class QueryBuilder { if (signature) { if (isPlainObject(value) && value.__type) { // Case 2 (User!) - typeOrValue = context.adapter.getInputTypeName(context.getModel(value.__type), action) + "!"; + // console.log('field: ', field) + typeOrValue = + context.adapter.getInputTypeName( + context.getModel(value.__type), + action, + field?.name + ) + "!"; //1 } else if (value instanceof Array && field) { const arg = QueryBuilder.findSchemaFieldForArgument(key, field, model, filter); @@ -368,7 +382,11 @@ export default class QueryBuilder { * @param {string} action Name of the current action like 'persist' or 'push' * @returns {string} */ - static buildRelationsQuery(model: null | Model, path: Array = [], action: string): string { + static buildRelationsQuery( + model: null | Model, + path: Array = [], + action: string + ): string { if (model === null) return ""; const context = Context.getInstance(); diff --git a/src/graphql/transformer.ts b/src/graphql/transformer.ts index 20edf75b..43aa92ea 100644 --- a/src/graphql/transformer.ts +++ b/src/graphql/transformer.ts @@ -23,6 +23,7 @@ export default class Transformer { * @param {Data} data Data to transform * @param {boolean} read Tells if this is a write or a read action. read is fetch, write is push and persist. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'ceatePost' * @param {Array} whitelist of fields * @param {Map>} outgoingRecords List of record IDs that are already added to the * outgoing data in order to detect recursion. @@ -34,6 +35,7 @@ export default class Transformer { data: Data, read: boolean, action: string, + mutationName: string, whitelist?: Array, outgoingRecords?: Map>, recursiveCall?: boolean @@ -67,6 +69,7 @@ export default class Transformer { value, model, action, + mutationName, whitelist ) ) { @@ -84,6 +87,7 @@ export default class Transformer { v, read, action, + mutationName, undefined, outgoingRecords, true @@ -106,6 +110,7 @@ export default class Transformer { value, read, action, + mutationName, undefined, outgoingRecords, true @@ -213,6 +218,7 @@ export default class Transformer { * @param {any} value Value of the field. * @param {Model} model Model class which contains the field. * @param {string} action Name of the current action like 'persist' or 'push' + * @param {string} mutationName Name of the current mutation like 'createPost' * @param {Array|undefined} whitelist Contains a list of fields which should always be included. * @returns {boolean} */ @@ -222,6 +228,7 @@ export default class Transformer { value: any, model: Model, action: string, + mutationName: string, whitelist?: Array ): boolean { // Always add fields on the whitelist. @@ -235,9 +242,9 @@ export default class Transformer { // Ignore empty fields if (value === null || value === undefined) return false; - + //1 // Ignore fields that don't exist in the input type - if (!this.inputTypeContainsField(model, fieldName, action)) return false; + if (!this.inputTypeContainsField(model, fieldName, action, mutationName)) return false; // Include all eager save connections if (model.getRelations().has(fieldName)) { @@ -262,13 +269,17 @@ export default class Transformer { * @param {string} fieldName * @param {string} action Name of the current action like 'persist' or 'push' */ - private static inputTypeContainsField(model: Model, fieldName: string, action: string): boolean { + private static inputTypeContainsField( + model: Model, + fieldName: string, + action: string, + mutationName: string + ): boolean { const context = Context.getInstance(); - const inputTypeName = context.adapter.getInputTypeName(model, action); - const inputType: GraphQLType | null = context.schema!.getType( - inputTypeName, - false - ); + // console.log('fieldName: ' + fieldName) + // console.log('model: ', model) + const inputTypeName = context.adapter.getInputTypeName(model, action, mutationName); //1 + const inputType: GraphQLType | null = context.schema!.getType(inputTypeName, false); if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`);