-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import express from 'express'; | ||
import {ApolloServer} from 'apollo-server-express'; | ||
import {buildSchemaSync} from 'type-graphql'; | ||
import DexResolver from '../resolvers/DexResolver'; | ||
|
||
const gqlServer = () => { | ||
const app = express(); | ||
const schema = buildSchemaSync({resolvers: [ DexResolver ]}); | ||
|
||
const apolloServer = new ApolloServer({ | ||
schema, | ||
introspection: true, | ||
playground: {endpoint: '/playground'}, | ||
}); | ||
|
||
apolloServer.applyMiddleware({app, path: '/', cors: true}); | ||
|
||
return app; | ||
}; | ||
|
||
export default gqlServer; |
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 |
---|---|---|
@@ -1,30 +1,16 @@ | ||
import 'reflect-metadata'; | ||
import * as functions from 'firebase-functions'; | ||
import express from 'express'; | ||
import {ApolloServer} from 'apollo-server-express'; | ||
import {buildSchemaSync} from 'type-graphql'; | ||
import DexResolver from './resolvers/DexResolver'; | ||
|
||
const schema = buildSchemaSync({resolvers: [ DexResolver ]}); | ||
const apolloServer = new ApolloServer({ | ||
schema, | ||
playground: {endpoint: '/playground'}, | ||
}); | ||
const app = express(); | ||
|
||
apolloServer.applyMiddleware({app}); | ||
|
||
app.get('/', (_req, res) => { | ||
return res.send('Looks like you hit a non-existing endpoint!'); | ||
}); | ||
import {https} from 'firebase-functions'; | ||
import gqlServer from './graphql/server'; | ||
|
||
// If we're not in the Cloud Functions environment, spin up a Node server | ||
if (!process.env.FIREBASE_CONFIG) { | ||
const PORT = process.env.PORT || 4000; | ||
app.listen(PORT, () => { | ||
console.log('server started on http://localhost:4000/graphql'); // eslint-disable-line no-console | ||
}); | ||
} | ||
// If (!process.env.FIREBASE_CONFIG) { | ||
// Const PORT = process.env.PORT || 4000; | ||
// App.listen(PORT, () => { | ||
// Console.log('server started on http://localhost:4000/graphql'); // eslint-disable-line no-console | ||
// }); | ||
// } | ||
|
||
const server = gqlServer(); | ||
|
||
export const api = functions.https.onRequest(app); | ||
export const api = https.onRequest(server); | ||
export * from './client'; |