Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ typings/
.serverless
.webpack
.cache-loader

# JetBrains Settings
.idea/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ And all this works without having to install Webpack, Babel, ESLint, etc. or man
- "babel-eslint"
- "babel-loader"
- "eslint-loader"
- "graphql-tag/loader"
- "@babel/runtime"
- "@babel/preset-env"
- "serverless-webpack"
Expand Down Expand Up @@ -282,6 +283,14 @@ import "./assets/style.css";
import "./assets/style.scss";
import "./assets/react.png";
```
### gql, graphql Files

Serverless Bundle automatically supports importing .gql, .graphql files.

``` js
import "./modules/users.gql";
import "./modules/messages.graphql";
```

### Externals vs forceExclude

Expand Down
41 changes: 40 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"eslint": "^5.16.0",
"eslint-config-strongloop": "^2.1.0",
"eslint-loader": "^2.2.1",
"graphql": "^15.2.0",
"graphql-tag": "^2.10.3",
"hard-source-webpack-plugin": "^0.13.1",
"ignore-loader": "^0.1.2",
"isomorphic-style-loader": "^5.1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ function loaders() {
"sass-loader"
]
},
{ test: /\.gif|\.svg|\.png|\.jpg|\.jpeg$/, loader: "ignore-loader" }
{ test: /\.gif|\.svg|\.png|\.jpg|\.jpeg$/, loader: "ignore-loader" },
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
}
]
};

Expand Down
6 changes: 6 additions & 0 deletions tests/graphql-loaders/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages

# Serverless directories
.serverless
17 changes: 17 additions & 0 deletions tests/graphql-loaders/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Users from "./modules/users.gql";
import Messages from "./modules/messages.graphql";

export const hello = async (event, context) => {
const statusCode =
typeof Users !== "undefined" && typeof Messages !== "undefined" ? 200 : 500;
return {
statusCode: statusCode,
body: JSON.stringify({
message:
statusCode === 200
? "Go Serverless v1.0! Your function executed successfully!"
: "Error importing graphql",
input: event
})
};
};
9 changes: 9 additions & 0 deletions tests/graphql-loaders/modules/messages.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type Messages {
user:ID!
messages:[Message]
}
type Message {
id:ID!
timestamp:String
message:String
}
5 changes: 5 additions & 0 deletions tests/graphql-loaders/modules/users.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Users {
id:ID!
name:String
nickname:String
}
5 changes: 5 additions & 0 deletions tests/graphql-loaders/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions tests/graphql-loaders/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "graphql-loader",
"version": "1.0.0",
"description": "",
"main": "handler.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
12 changes: 12 additions & 0 deletions tests/graphql-loaders/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
service: my-service

plugins:
- '../../index'

provider:
name: aws
runtime: nodejs10.x

functions:
hello:
handler: handler.hello
5 changes: 5 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ test("isomorphic loaders", () => {
expect(results).not.toMatch(errorRegex);
});

test("graphql loaders", () => {
const results = runSlsCommand("graphql-loaders");
expect(results).not.toMatch(errorRegex);
});

function clearNodeModules(cwd) {
const { stdout, error } = spawnSync("rm", ["-rf", "node_modules/"], {
cwd,
Expand Down