-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from uport-project/feature/cli-graphql
feat: Graphql server in CLI
- Loading branch information
Showing
5 changed files
with
919 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ApolloServer } from 'apollo-server' | ||
import program from 'commander' | ||
import * as Daf from 'daf-core' | ||
import * as W3c from 'daf-w3c' | ||
import * as DIDComm from 'daf-did-comm' | ||
import { Gql as DataGql } from 'daf-data-store' | ||
import merge from 'lodash.merge' | ||
import { core, dataStore } from './setup' | ||
import { listen } from './services' | ||
program | ||
.command('graphql') | ||
.description('GraphQL server') | ||
.option('-p, --port <port>', 'Port') | ||
.option('-l, --listen', 'Listen for new messages') | ||
.action(async cmd => { | ||
const server = new ApolloServer({ | ||
typeDefs: [ | ||
Daf.Gql.baseTypeDefs, | ||
Daf.Gql.Core.typeDefs, | ||
Daf.Gql.IdentityManager.typeDefs, | ||
DataGql.typeDefs, | ||
DIDComm.Gql.typeDefs, | ||
W3c.Gql.typeDefs, | ||
], | ||
resolvers: merge( | ||
Daf.Gql.Core.resolvers, | ||
Daf.Gql.IdentityManager.resolvers, | ||
DataGql.resolvers, | ||
DIDComm.Gql.resolvers, | ||
W3c.Gql.resolvers, | ||
), | ||
context: () => ({ dataStore, core }), | ||
introspection: true, | ||
}) | ||
const info = await server.listen({ port: cmd.port }) | ||
console.log(`🚀 Server ready at ${info.url}`) | ||
|
||
if (cmd.listen) { | ||
await listen() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.