From 967b9168536e5c5a2ba484e3f912ba4661952f8f Mon Sep 17 00:00:00 2001 From: Simonas Karuzas Date: Wed, 8 Jul 2020 13:36:57 +0300 Subject: [PATCH] feat: GraphQL w3c --- packages/daf-graphql/src/base-type-def.ts | 2 ++ packages/daf-graphql/src/methods/index.ts | 2 ++ packages/daf-graphql/src/methods/w3c.ts | 38 +++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 packages/daf-graphql/src/methods/w3c.ts diff --git a/packages/daf-graphql/src/base-type-def.ts b/packages/daf-graphql/src/base-type-def.ts index f60b8da44..85deda2d7 100644 --- a/packages/daf-graphql/src/base-type-def.ts +++ b/packages/daf-graphql/src/base-type-def.ts @@ -11,6 +11,8 @@ scalar Object scalar Date scalar VerifiablePresentation scalar VerifiableCredential +scalar Presentation +scalar Credential type Message { id: ID! diff --git a/packages/daf-graphql/src/methods/index.ts b/packages/daf-graphql/src/methods/index.ts index ffc0dd9cc..b672f1119 100644 --- a/packages/daf-graphql/src/methods/index.ts +++ b/packages/daf-graphql/src/methods/index.ts @@ -2,9 +2,11 @@ import { IAgentGraphQLMethod } from '../types' import identityManager from './identity-manager' import resolver from './resolver' import messageHandler from './message-handler' +import w3c from './w3c' export const supportedMethods: Record = { ...identityManager, ...resolver, ...messageHandler, + ...w3c, } diff --git a/packages/daf-graphql/src/methods/w3c.ts b/packages/daf-graphql/src/methods/w3c.ts new file mode 100644 index 000000000..f8fce7424 --- /dev/null +++ b/packages/daf-graphql/src/methods/w3c.ts @@ -0,0 +1,38 @@ +import { IAgentGraphQLMethod } from '../types' + +export const createVerifiableCredential: IAgentGraphQLMethod = { + type: 'Mutation', + query: ` + mutation createVerifiableCredential($credential: Credential!, $proofFormat: String, $save: Boolean) { + createVerifiableCredential(credential: $credential, proofFormat: $proofFormat, save: $save) + } + `, + typeDef: ` + + extend type Mutation { + createVerifiableCredential(credential: Credential!, proofFormat: String, save: Boolean): VerifiableCredential + } + `, +} + +export const createVerifiablePresentation: IAgentGraphQLMethod = { + type: 'Mutation', + query: ` + mutation createVerifiablePresentation($presentation: Presentation!, $proofFormat: String, $save: Boolean) { + createVerifiablePresentation(presentation: $presentation, proofFormat: $proofFormat, save: $save) + } + `, + typeDef: ` + + extend type Mutation { + createVerifiablePresentation(presentation: Presentation!, proofFormat: String, save: Boolean): VerifiableCredential + } + `, +} + +export const supportedMethods: Record = { + createVerifiableCredential, + createVerifiablePresentation, +} + +export default supportedMethods