Skip to content

Commit

Permalink
feat: Add GraphQL support
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Sep 26, 2023
1 parent c5649b5 commit a7e0357
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/graphql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createGraphQLSchema } from 'openapi-to-graphql';
import { graphqlHTTP } from 'express-graphql';
import fs from 'fs';
import path from 'path';

const openApiSpec = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../openapi/swagger.json'), 'utf8'));
const graphqlSchema = createGraphQLSchema(openApiSpec);

export default function(app) {
app.use('/graphql', graphqlHTTP({
schema: graphqlSchema,
graphiql: true
}));
}

0 comments on commit a7e0357

Please sign in to comment.