-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: #374 deploy graphql to lambda * chore: #374 deploy graphql to lambda * chore: revert back fetcher from @reapit/elements Revert change code in fetcher api * chore: remove no-hoist in package.json for graphql-server * chore: remove isomophic fetch from graphql-server
- Loading branch information
Showing
9 changed files
with
1,322 additions
and
95 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
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,49 @@ | ||
service: graphql-server | ||
plugins: | ||
- serverless-webpack | ||
custom: | ||
env: ${file(../../reapit-config.json)} | ||
webpack: | ||
webpackConfig: 'webpack.config.js' | ||
includeModules: true | ||
packager: 'yarn' | ||
packagerOptions: | ||
noFrozenLockFile: false | ||
excludeFiles: src/**/*.test.ts | ||
keepOutputDirectory: true | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs10.x | ||
stage: ${opt:stage, 'dev'} | ||
region: eu-west-2 | ||
deploymentBucket: | ||
name: graphql-server.${self:provider.stage} | ||
blockPublicAccess: false | ||
environment: | ||
NODE_ENV: 'production' | ||
COGNITO_USERPOOL_ID: ${self:custom.env.${file(./yml-helpers.js):provider.stage.uppercase}.COGNITO_USERPOOL_ID} | ||
MARKETPLACE_API_BASE_URL: ${self:custom.env.${file(./yml-helpers.js):provider.stage.uppercase}.MARKETPLACE_API_BASE_URL} | ||
|
||
package: | ||
individually: true | ||
include: | ||
- dist/** | ||
exclude: | ||
- package.json | ||
- node_modules/** | ||
- error.log | ||
- info.log | ||
- jest.config.js | ||
- nodemon.json | ||
- serverless.yml | ||
- src/** | ||
- tsconfig.json | ||
- yml-helpers.js | ||
|
||
functions: | ||
graphqlHandler: | ||
handler: src/index.graphqlHandler | ||
events: | ||
- http: ANY / | ||
- http: 'ANY {proxy+}' |
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,16 @@ | ||
import { ApolloServer } from 'apollo-server-lambda' | ||
import { importSchema } from 'graphql-import' | ||
import resolvers from './resolvers' | ||
|
||
const typeDefs = importSchema('./src/schema.graphql') | ||
|
||
const server = new ApolloServer({ | ||
typeDefs: typeDefs, | ||
resolvers, | ||
playground: true, | ||
introspection: true, | ||
}) | ||
|
||
export const graphqlHandler = server.createHandler() | ||
|
||
export default graphqlHandler |
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,68 @@ | ||
const path = require('path') | ||
const slsw = require('serverless-webpack') | ||
const CopyPlugin = require('copy-webpack-plugin') | ||
|
||
module.exports = { | ||
entry: slsw.lib.entries, | ||
target: 'node', | ||
stats: 'minimal', | ||
mode: slsw.lib.webpack.isLocal ? 'development' : 'production', | ||
node: false, | ||
optimization: { | ||
minimize: true, | ||
}, | ||
devtool: 'inline-cheap-module-source-map', | ||
output: { | ||
libraryTarget: 'commonjs', | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'index.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [['@babel/preset-env', { targets: { node: '12' }, useBuiltIns: 'usage', corejs: 3 }]], | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /.ts?$/, | ||
exclude: /node_modules/, | ||
use: [{ loader: 'ts-loader', options: { transpileOnly: true } }], | ||
}, | ||
{ | ||
test: /\.(graphql|gql)$/, | ||
exclude: /node_modules/, | ||
use: 'graphql-tag/loader', | ||
}, | ||
{ | ||
test: /\.mjs$/, | ||
include: /node_modules/, | ||
type: 'javascript/auto', | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
new CopyPlugin([ | ||
{ | ||
test: /\.(graphql|gql)$/, | ||
ignore: ['*.ts', '*.test.ts', 'tests/**/*'], | ||
from: 'src', | ||
to: 'src', | ||
force: true, | ||
}, | ||
]), | ||
], | ||
resolve: { | ||
extensions: ['.ts', '.js', '.mjs', '.gql', '.graphql', '.json'], | ||
alias: { | ||
'@': path.resolve(__dirname, 'src/'), | ||
}, | ||
}, | ||
} |
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,19 @@ | ||
// https://stackoverflow.com/questions/48226686/serverless-yml-touppercase#48249468 | ||
module.exports.provider = serverless => { | ||
// The `serverless` argument containers all the information in the .yml file | ||
const provider = serverless.service.provider | ||
|
||
return Object.entries(provider).reduce( | ||
(accumulator, [key, value]) => ({ | ||
...accumulator, | ||
[key]: | ||
typeof value === 'string' | ||
? { | ||
lowercase: value.toLowerCase(), | ||
uppercase: value.toUpperCase(), | ||
} | ||
: value, | ||
}), | ||
{}, | ||
) | ||
} |
Oops, something went wrong.