Skip to content

Commit

Permalink
feat: GraphQL methods
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Oct 5, 2020
1 parent a48e7ef commit 6446f2d
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/daf-graphql/src/base-type-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ type Message {
credentials: [VerifiableCredential]
}
input MessageInput {
id: ID!
createdAt: String
expiresAt: String
threadId: String
type: String!
raw: String
data: Object
replyTo: [String]
replyUrl: String
from: String
to: String
metaData: [MetaDataInput]
presentations: [VerifiablePresentation]
credentials: [VerifiableCredential]
}
type MetaData {
type: String!
value: String
Expand Down
15 changes: 15 additions & 0 deletions packages/daf-graphql/src/methods/data-store-orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ export const dataStoreORMGetIdentities: IAgentGraphQLMethod = {
`,
}

export const dataStoreORMGetMessagesCount: IAgentGraphQLMethod = {
type: 'Query',
query: `
query dataStoreORMGetMessagesCount($where: [MessagesWhere], $order: [MessagesOrder]) {
dataStoreORMGetMessagesCount(where: $where, order: $order)
}
`,
typeDef: `
extend type Query {
dataStoreORMGetMessagesCount(where: [MessagesWhere], order: [MessagesOrder]): Int
}
`,
}

export const dataStoreORMGetIdentitiesCount: IAgentGraphQLMethod = {
type: 'Query',
query: `
Expand Down Expand Up @@ -256,6 +270,7 @@ export const dataStoreORMGetVerifiablePresentationsCount: IAgentGraphQLMethod =

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
dataStoreORMGetMessages,
dataStoreORMGetMessagesCount,
dataStoreORMGetVerifiableCredentials,
dataStoreORMGetVerifiableCredentialsCount,
dataStoreORMGetVerifiablePresentations,
Expand Down
15 changes: 15 additions & 0 deletions packages/daf-graphql/src/methods/data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ export const dataStoreGetMessage: IAgentGraphQLMethod = {
`,
}

export const dataStoreSaveMessage: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation dataStoreSaveMessage($message: MessageInput!) {
dataStoreSaveMessage(message: $message)
}
`,
typeDef: `
extend type Mutation {
dataStoreSaveMessage(message: MessageInput!): String!
}
`,
}

export const dataStoreSaveVerifiableCredential: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
Expand Down Expand Up @@ -90,6 +104,7 @@ export const dataStoreSaveVerifiablePresentation: IAgentGraphQLMethod = {

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
dataStoreGetMessage,
dataStoreSaveMessage,
dataStoreSaveVerifiableCredential,
dataStoreGetVerifiableCredential,
dataStoreGetVerifiablePresentation,
Expand Down
2 changes: 2 additions & 0 deletions packages/daf-graphql/src/methods/message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const handleMessage: IAgentGraphQLMethod = {
replyUrl
from
to
presentations
credentials
metaData {
type
value
Expand Down
32 changes: 32 additions & 0 deletions packages/daf-graphql/src/methods/sdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,40 @@ export const getVerifiableCredentialsForSdr: IAgentGraphQLMethod = {
`,
}

export const validatePresentationAgainstSdr: IAgentGraphQLMethod = {
type: 'Query',
query: `
query validatePresentationAgainstSdr($sdr: SelectiveDisclosureRequest!, $presentation: VerifiablePresentation) {
validatePresentationAgainstSdr(sdr: $sdr, presentation: $presentation)
}
`,
typeDef: `
scalar ValidatePresentationAgainstSdrResult
extend type Query {
validatePresentationAgainstSdr(sdr: SelectiveDisclosureRequest!, presentation: VerifiablePresentation): ValidatePresentationAgainstSdrResult
}
`,
}

export const createSelectiveDisclosureRequest: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation createSelectiveDisclosureRequest($data: SelectiveDisclosureRequestInput!) {
createSelectiveDisclosureRequest(data: $data)
}
`,
typeDef: `
scalar SelectiveDisclosureRequestInput
extend type Mutation {
createSelectiveDisclosureRequest(data: SelectiveDisclosureRequestInput!): String!
}
`,
}

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
getVerifiableCredentialsForSdr,
createSelectiveDisclosureRequest,
validatePresentationAgainstSdr,
}

export default supportedMethods

0 comments on commit 6446f2d

Please sign in to comment.