From dd624c29a103b6f2e279d1b853a26a040ba7d6a9 Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Wed, 15 Apr 2020 15:46:06 +0300 Subject: [PATCH] feat: Gql Not operator --- packages/daf-core/src/graphql/graphql-core.ts | 131 +++++++++++++++--- 1 file changed, 110 insertions(+), 21 deletions(-) diff --git a/packages/daf-core/src/graphql/graphql-core.ts b/packages/daf-core/src/graphql/graphql-core.ts index 2f9f9d5a8..c68b3fe7a 100644 --- a/packages/daf-core/src/graphql/graphql-core.ts +++ b/packages/daf-core/src/graphql/graphql-core.ts @@ -31,6 +31,7 @@ export interface Order { export interface Where { column: string value?: string[] + not?: boolean op?: | 'LessThan' | 'LessThanOrEqual' @@ -109,6 +110,9 @@ function transformFindInput(input: FindInput): FindManyOptions { default: where[item.column] = In(item.value) } + if (item.not === true) { + where[item.column] = Not(where[item.column]) + } } result['where'] = where } @@ -272,6 +276,7 @@ export const typeDefs = ` input MessagesWhere { column: MessagesColumns! value: [String] + not: Boolean op: WhereOperation } @@ -287,47 +292,127 @@ export const typeDefs = ` skip: Int } - input OrderOptions { - field: String! + + + enum IdentitiesColumns { + saveDate + updateDate + did + provider + } + + input IdentitiesWhere { + column: IdentitiesColumns! + value: [String] + not: Boolean + op: WhereOperation + } + + input IdentitiesOrder { + column: IdentitiesColumns! direction: OrderDirection! } - input FindOptions { + input IdentitiesInput { + where: [IdentitiesWhere] + order: [IdentitiesOrder] take: Int skip: Int - order: [OrderOptions] } - input IdentitiesInput { - options: FindOptions + + enum PresentationsColumns { + id + issuanceDate + expirationDate + context + type + issuer + audience } + input PresentationsWhere { + column: PresentationsColumns! + value: [String] + not: Boolean + op: WhereOperation + } + input PresentationsOrder { + column: PresentationsColumns! + direction: OrderDirection! + } input PresentationsInput { - issuer: [ID] - audience: [ID] - type: [String] - context: [String] - options: FindOptions + where: [PresentationsWhere] + order: [PresentationsOrder] + take: Int + skip: Int + } + + + enum CredentialsColumns { + id + issuanceDate + expirationDate + context + type + issuer + subject + } + + input CredentialsWhere { + column: CredentialsColumns! + value: [String] + not: Boolean + op: WhereOperation + } + + input CredentialsOrder { + column: CredentialsColumns! + direction: OrderDirection! } input CredentialsInput { - issuer: [ID] - subject: [ID] - type: [String] - context: [String] - options: FindOptions + where: [CredentialsWhere] + order: [CredentialsOrder] + take: Int + skip: Int } - input ClaimsInput { - issuer: [ID] - subject: [ID] - type: [String] + + enum ClaimsColumns { + issuanceDate + expirationDate + context + credentialType + type + value + issuer + subject + } + + input ClaimsWhere { + column: ClaimsColumns! value: [String] - options: FindOptions + not: Boolean + op: WhereOperation + } + + input ClaimsOrder { + column: ClaimsColumns! + direction: OrderDirection! + } + + input ClaimsInput { + where: [ClaimsWhere] + order: [ClaimsOrder] + take: Int + skip: Int } + + extend type Query { identity(did: ID!): Identity identities(input: IdentitiesInput): [Identity] @@ -354,6 +439,8 @@ export const typeDefs = ` extend type Identity { shortDid: String! latestClaimValue(type: String): String + saveDate: Date! + updateDate: Date! } scalar Object @@ -385,6 +472,7 @@ export const typeDefs = ` type Presentation { hash: ID! + id: String raw: String! issuer: Identity! audience: Identity! @@ -398,6 +486,7 @@ export const typeDefs = ` type Credential { hash: ID! + id: String raw: String! issuer: Identity! subject: Identity