Skip to content

Commit 01a927f

Browse files
committed
lint & build
1 parent fba849d commit 01a927f

9 files changed

+102
-10
lines changed

Diff for: dist/graphql/transformer.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export default class Transformer {
3838
* @returns {boolean}
3939
*/
4040
static shouldIncludeOutgoingField(forFilter: boolean, fieldName: string, value: any, model: Model, whitelist?: Array<String>): boolean;
41+
/**
42+
* Tells whether a field is in the input type.
43+
* @param {Model} model
44+
* @param {string} fieldName
45+
*/
46+
private static inputTypeContainsField;
4147
/**
4248
* Registers a record for recursion detection.
4349
* @param {Map<string, Array<string>>} records Map of IDs.

Diff for: dist/vuex-orm-graphql.cjs.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -14269,6 +14269,9 @@ var Transformer = /** @class */ (function () {
1426914269
// Ignore empty fields
1427014270
if (value === null || value === undefined)
1427114271
return false;
14272+
// Ignore fields that don't exist in the input type
14273+
if (!this.inputTypeContainsField(model, fieldName))
14274+
return false;
1427214275
// Include all eager save connections
1427314276
if (model.getRelations().has(fieldName)) {
1427414277
// We never add relations to filters.
@@ -14284,6 +14287,18 @@ var Transformer = /** @class */ (function () {
1428414287
// Everything else is ok
1428514288
return true;
1428614289
};
14290+
/**
14291+
* Tells whether a field is in the input type.
14292+
* @param {Model} model
14293+
* @param {string} fieldName
14294+
*/
14295+
Transformer.inputTypeContainsField = function (model, fieldName) {
14296+
var inputTypeName = model.singularName + "Input";
14297+
var inputType = Context.getInstance().schema.getType(inputTypeName, false);
14298+
if (inputType === null)
14299+
throw new Error("Type " + inputType + " doesn't exist.");
14300+
return inputType.inputFields.find(function (f) { return f.name === fieldName; }) != null;
14301+
};
1428714302
/**
1428814303
* Registers a record for recursion detection.
1428914304
* @param {Map<string, Array<string>>} records Map of IDs.
@@ -15131,7 +15146,9 @@ var QueryBuilder = /** @class */ (function () {
1513115146
}
1513215147
});
1513315148
if (!first) {
15134-
if (!signature && filter && Context.getInstance().adapter.getArgumentMode() === exports.ArgumentMode.TYPE)
15149+
if (!signature &&
15150+
filter &&
15151+
Context.getInstance().adapter.getArgumentMode() === exports.ArgumentMode.TYPE)
1513515152
returnValue = "filter: { " + returnValue + " }";
1513615153
returnValue = "(" + returnValue + ")";
1513715154
}

Diff for: dist/vuex-orm-graphql.esm-bundler.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -14243,6 +14243,9 @@ class Transformer {
1424314243
// Ignore empty fields
1424414244
if (value === null || value === undefined)
1424514245
return false;
14246+
// Ignore fields that don't exist in the input type
14247+
if (!this.inputTypeContainsField(model, fieldName))
14248+
return false;
1424614249
// Include all eager save connections
1424714250
if (model.getRelations().has(fieldName)) {
1424814251
// We never add relations to filters.
@@ -14258,6 +14261,18 @@ class Transformer {
1425814261
// Everything else is ok
1425914262
return true;
1426014263
}
14264+
/**
14265+
* Tells whether a field is in the input type.
14266+
* @param {Model} model
14267+
* @param {string} fieldName
14268+
*/
14269+
static inputTypeContainsField(model, fieldName) {
14270+
const inputTypeName = `${model.singularName}Input`;
14271+
const inputType = Context.getInstance().schema.getType(inputTypeName, false);
14272+
if (inputType === null)
14273+
throw new Error(`Type ${inputType} doesn't exist.`);
14274+
return inputType.inputFields.find(f => f.name === fieldName) != null;
14275+
}
1426114276
/**
1426214277
* Registers a record for recursion detection.
1426314278
* @param {Map<string, Array<string>>} records Map of IDs.
@@ -15144,7 +15159,9 @@ class QueryBuilder {
1514415159
}
1514515160
});
1514615161
if (!first) {
15147-
if (!signature && filter && Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
15162+
if (!signature &&
15163+
filter &&
15164+
Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
1514815165
returnValue = `filter: { ${returnValue} }`;
1514915166
returnValue = `(${returnValue})`;
1515015167
}

Diff for: dist/vuex-orm-graphql.esm.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -14243,6 +14243,9 @@ class Transformer {
1424314243
// Ignore empty fields
1424414244
if (value === null || value === undefined)
1424514245
return false;
14246+
// Ignore fields that don't exist in the input type
14247+
if (!this.inputTypeContainsField(model, fieldName))
14248+
return false;
1424614249
// Include all eager save connections
1424714250
if (model.getRelations().has(fieldName)) {
1424814251
// We never add relations to filters.
@@ -14258,6 +14261,18 @@ class Transformer {
1425814261
// Everything else is ok
1425914262
return true;
1426014263
}
14264+
/**
14265+
* Tells whether a field is in the input type.
14266+
* @param {Model} model
14267+
* @param {string} fieldName
14268+
*/
14269+
static inputTypeContainsField(model, fieldName) {
14270+
const inputTypeName = `${model.singularName}Input`;
14271+
const inputType = Context.getInstance().schema.getType(inputTypeName, false);
14272+
if (inputType === null)
14273+
throw new Error(`Type ${inputType} doesn't exist.`);
14274+
return inputType.inputFields.find(f => f.name === fieldName) != null;
14275+
}
1426114276
/**
1426214277
* Registers a record for recursion detection.
1426314278
* @param {Map<string, Array<string>>} records Map of IDs.
@@ -15144,7 +15159,9 @@ class QueryBuilder {
1514415159
}
1514515160
});
1514615161
if (!first) {
15147-
if (!signature && filter && Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
15162+
if (!signature &&
15163+
filter &&
15164+
Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
1514815165
returnValue = `filter: { ${returnValue} }`;
1514915166
returnValue = `(${returnValue})`;
1515015167
}

Diff for: dist/vuex-orm-graphql.esm.prod.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -14243,6 +14243,9 @@ class Transformer {
1424314243
// Ignore empty fields
1424414244
if (value === null || value === undefined)
1424514245
return false;
14246+
// Ignore fields that don't exist in the input type
14247+
if (!this.inputTypeContainsField(model, fieldName))
14248+
return false;
1424614249
// Include all eager save connections
1424714250
if (model.getRelations().has(fieldName)) {
1424814251
// We never add relations to filters.
@@ -14258,6 +14261,18 @@ class Transformer {
1425814261
// Everything else is ok
1425914262
return true;
1426014263
}
14264+
/**
14265+
* Tells whether a field is in the input type.
14266+
* @param {Model} model
14267+
* @param {string} fieldName
14268+
*/
14269+
static inputTypeContainsField(model, fieldName) {
14270+
const inputTypeName = `${model.singularName}Input`;
14271+
const inputType = Context.getInstance().schema.getType(inputTypeName, false);
14272+
if (inputType === null)
14273+
throw new Error(`Type ${inputType} doesn't exist.`);
14274+
return inputType.inputFields.find(f => f.name === fieldName) != null;
14275+
}
1426114276
/**
1426214277
* Registers a record for recursion detection.
1426314278
* @param {Map<string, Array<string>>} records Map of IDs.
@@ -15144,7 +15159,9 @@ class QueryBuilder {
1514415159
}
1514515160
});
1514615161
if (!first) {
15147-
if (!signature && filter && Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
15162+
if (!signature &&
15163+
filter &&
15164+
Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE)
1514815165
returnValue = `filter: { ${returnValue} }`;
1514915166
returnValue = `(${returnValue})`;
1515015167
}

Diff for: dist/vuex-orm-graphql.global.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -14268,6 +14268,9 @@ var VuexORMGraphQLPlugin = (function (exports) {
1426814268
// Ignore empty fields
1426914269
if (value === null || value === undefined)
1427014270
return false;
14271+
// Ignore fields that don't exist in the input type
14272+
if (!this.inputTypeContainsField(model, fieldName))
14273+
return false;
1427114274
// Include all eager save connections
1427214275
if (model.getRelations().has(fieldName)) {
1427314276
// We never add relations to filters.
@@ -14283,6 +14286,18 @@ var VuexORMGraphQLPlugin = (function (exports) {
1428314286
// Everything else is ok
1428414287
return true;
1428514288
};
14289+
/**
14290+
* Tells whether a field is in the input type.
14291+
* @param {Model} model
14292+
* @param {string} fieldName
14293+
*/
14294+
Transformer.inputTypeContainsField = function (model, fieldName) {
14295+
var inputTypeName = model.singularName + "Input";
14296+
var inputType = Context.getInstance().schema.getType(inputTypeName, false);
14297+
if (inputType === null)
14298+
throw new Error("Type " + inputType + " doesn't exist.");
14299+
return inputType.inputFields.find(function (f) { return f.name === fieldName; }) != null;
14300+
};
1428614301
/**
1428714302
* Registers a record for recursion detection.
1428814303
* @param {Map<string, Array<string>>} records Map of IDs.
@@ -15130,7 +15145,9 @@ var VuexORMGraphQLPlugin = (function (exports) {
1513015145
}
1513115146
});
1513215147
if (!first) {
15133-
if (!signature && filter && Context.getInstance().adapter.getArgumentMode() === exports.ArgumentMode.TYPE)
15148+
if (!signature &&
15149+
filter &&
15150+
Context.getInstance().adapter.getArgumentMode() === exports.ArgumentMode.TYPE)
1513415151
returnValue = "filter: { " + returnValue + " }";
1513515152
returnValue = "(" + returnValue + ")";
1513615153
}

Diff for: dist/vuex-orm-graphql.global.prod.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: src/graphql/query-builder.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ export default class QueryBuilder {
242242
!signature &&
243243
filter &&
244244
Context.getInstance().adapter.getArgumentMode() === ArgumentMode.TYPE
245-
)
245+
) {
246246
returnValue = `filter: { ${returnValue} }`;
247+
}
248+
247249
returnValue = `(${returnValue})`;
248250
}
249251
}

Diff for: src/graphql/transformer.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Data, Field } from "../support/interfaces";
1+
import { Data, GraphQLType } from "../support/interfaces";
22
import Model from "../orm/model";
33
import { Model as ORMModel, Relation } from "@vuex-orm/core";
44
import Context from "../common/context";
@@ -10,7 +10,6 @@ import {
1010
singularize
1111
} from "../support/utils";
1212
import { ConnectionMode } from "../adapters/adapter";
13-
import { GraphQLType } from "../support/interfaces";
1413

1514
/**
1615
* This class provides methods to transform incoming data from GraphQL in to a format Vuex-ORM understands and
@@ -257,7 +256,7 @@ export default class Transformer {
257256

258257
if (inputType === null) throw new Error(`Type ${inputType} doesn't exist.`);
259258

260-
return inputType.inputFields!.find(f => f.name === fieldName) != null;
259+
return inputType.inputFields!.find(f => f.name === fieldName) !== undefined;
261260
}
262261

263262
/**

0 commit comments

Comments
 (0)