@oridune/epic-odm
Advanced tools
Comparing version 1.0.54 to 1.0.55
{ | ||
"name": "@oridune/epic-odm", | ||
"version": "1.0.54", | ||
"version": "1.0.55", | ||
"description": "Install 1 ODM and code once with any database driver.", | ||
@@ -33,3 +33,2 @@ "main": "./src/index.js", | ||
"@types/node": "^17.0.21", | ||
"graphql": "^16.5.0", | ||
"jest": "^28.1.0", | ||
@@ -43,2 +42,3 @@ "mongodb": "^4.8.1", | ||
"dependencies": { | ||
"graphql": "^16.5.0", | ||
"pluralize": "^8.0.0", | ||
@@ -45,0 +45,0 @@ "reflect-metadata": "^0.1.13" |
@@ -0,1 +1,2 @@ | ||
import { GraphQLObjectType, GraphQLList } from "graphql"; | ||
import { BaseModel } from "../model/base"; | ||
@@ -10,2 +11,4 @@ export declare type FieldDataTypes = StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor; | ||
type: FieldDataTypes; | ||
/** Custom GraphQL Type */ | ||
graphQLType?: GraphQLObjectType | GraphQLList<any>; | ||
/** List of String choices */ | ||
@@ -12,0 +15,0 @@ choices?: Array<string>; |
import { BaseModel } from "./base"; | ||
import { Aggregation, ModelPayload, Mutable } from "./utils"; | ||
import { GraphQLList, GraphQLObjectType } from "graphql"; | ||
import { GraphQLObjectType, GraphQLList } from "graphql"; | ||
export declare type DatabaseCommandType = "create" | "createOne" | "find" | "findOne" | "update" | "save" | "delete"; | ||
@@ -16,2 +16,3 @@ export interface DatabaseCommand<M extends typeof BaseModel, T extends DatabaseCommandType> { | ||
static GraphQLObjectType?: GraphQLObjectType; | ||
static GraphQLList?: GraphQLList<any>; | ||
static new<M extends typeof BaseModel>(this: M, data: ModelPayload<Required<M["prototype"]>>): M["prototype"]; | ||
@@ -18,0 +19,0 @@ static toGraphQLObjectType<M extends typeof BaseModel>(this: M): GraphQLObjectType; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const model_1 = require("../decorators/model"); | ||
const graphql_1 = require("graphql"); | ||
class BaseModelStatic { | ||
@@ -18,3 +19,3 @@ static new(data) { | ||
// Return from memory if already created. | ||
if (this.GraphQLObjectType instanceof require("graphql").GraphQLObjectType) | ||
if (this.GraphQLObjectType instanceof graphql_1.GraphQLObjectType) | ||
return this.GraphQLObjectType; | ||
@@ -24,3 +25,3 @@ // Get Model Options | ||
// Create Object Type From Model | ||
return (this.GraphQLObjectType = new (require("graphql").GraphQLObjectType)({ | ||
return (this.GraphQLObjectType = new graphql_1.GraphQLObjectType({ | ||
name: this.name, | ||
@@ -33,14 +34,10 @@ description: ModelOptions.description, | ||
for (const Field of Object.values(ModelOptions.fields)) | ||
Fields[Field.options.name] = { | ||
type: Field.dataType === Number | ||
? require("graphql").GraphQLFloat | ||
: Field.dataType === Boolean | ||
? require("graphql").GraphQLBoolean | ||
: Field.dataType === Object || Field.dataType === Array | ||
? new (require("graphql").GraphQLScalarType)({ | ||
name: "Object", | ||
description: "Unknown object type.", | ||
}) | ||
: require("graphql").GraphQLString, | ||
}; | ||
if ([Number, Boolean, String].includes(Field.dataType)) | ||
Fields[Field.options.name] = { | ||
type: Field.options.graphQLType || Field.dataType === Number | ||
? graphql_1.GraphQLFloat | ||
: Field.dataType === Boolean | ||
? graphql_1.GraphQLBoolean | ||
: graphql_1.GraphQLString, | ||
}; | ||
// Embed to Fields | ||
@@ -59,4 +56,4 @@ for (const Embed of Object.values(ModelOptions.embeds)) | ||
: Relation.reference() === this | ||
? new (require("graphql").GraphQLList)(this.GraphQLObjectType) | ||
: new (require("graphql").GraphQLList)(Relation.reference().toGraphQLObjectType()), | ||
? new graphql_1.GraphQLList(this.GraphQLObjectType) | ||
: new graphql_1.GraphQLList(Relation.reference().toGraphQLObjectType()), | ||
}; | ||
@@ -68,3 +65,7 @@ return Fields; | ||
static toGraphQLObjectTypeList() { | ||
return new (require("graphql").GraphQLList)(this.toGraphQLObjectType()); | ||
// Return from memory if already created. | ||
if (this.GraphQLList instanceof graphql_1.GraphQLList) | ||
return this.GraphQLList; | ||
// Create Object Type List From Model | ||
return (this.GraphQLList = new graphql_1.GraphQLList(this.toGraphQLObjectType())); | ||
} | ||
@@ -71,0 +72,0 @@ static create(payload) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111872
10
2246
3
+ Addedgraphql@^16.5.0
+ Addedgraphql@16.9.0(transitive)