Skip to content

Commit

Permalink
feat: GraphQL message handler
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat authored and mirceanis committed Sep 7, 2020
1 parent 04b5a0b commit 10d31cc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/daf-graphql/src/base-type-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,30 @@ type Identity {
scalar Object
scalar Date
scalar VerifiablePresentation
scalar VerifiableCredential
type Message {
id: ID!
createdAt: Date
expiresAt: Date
threadId: String
type: String!
raw: String
data: Object
replyTo: [String]
replyUrl: String
from: String
to: String
metaData: [MetaData]
presentations: [VerifiablePresentation]
credentials: [VerifiableCredential]
}
type MetaData {
type: String!
value: String
}
`
2 changes: 2 additions & 0 deletions packages/daf-graphql/src/methods/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { IAgentGraphQLMethod } from '../types'
import identityManager from './identity-manager'
import resolver from './resolver'
import messageHandler from './message-handler'

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
...identityManager,
...resolver,
...messageHandler,
}
42 changes: 42 additions & 0 deletions packages/daf-graphql/src/methods/message-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { IAgentGraphQLMethod } from '../types'

export const handleMessage: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation handleMessage($raw: String!, $metaData: [MetaDataInput], $save: Boolean) {
handleMessage(raw: $raw, metaData: $metaData, save: $save) {
id
createdAt
expiresAt
threadId
type
raw
data
replyTo
replyUrl
from
to
metaData {
type
value
}
}
}
`,
typeDef: `
input MetaDataInput {
type: String!
value: String
}
extend type Mutation {
handleMessage(raw: String!, metaData: [MetaDataInput], save: Boolean = true): Message
}
`,
}

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
handleMessage,
}

export default supportedMethods

0 comments on commit 10d31cc

Please sign in to comment.