branch: elpa/graphql-mode
commit eed3c6ca1c7b3ad77003985662f36d5a5ab3641f
Author: David Vazquez Pua <[email protected]>
Commit: David Vazquez Pua <[email protected]>
Create sample GraphQL server
---
test/.gitignore | 1 +
test/index.js | 23 +++++++++++++++++++++++
test/package.json | 16 ++++++++++++++++
test/schema.graphql | 3 +++
test/simple-query.graphql | 3 +++
5 files changed, 46 insertions(+)
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000000..c2658d7d1b
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000000..c5adfc28ff
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,23 @@
+'use strict';
+
+var express = require('express');
+var graphqlHTTP = require('express-graphql');
+var buildSchema = require('graphql').buildSchema;
+
+var fs = require('fs');
+
+var schemaContent = fs.readFileSync(__dirname + '/schema.graphql', 'utf-8');
+var schema = buildSchema(schemaContent);
+
+var root = { hello: () => 'Hello world!' };
+
+var app = express();
+app.use('/graphql', graphqlHTTP({
+ schema: schema,
+ rootValue: root,
+ graphiql: true
+}));
+
+const PORT = 4000;
+
+app.listen(PORT, () => console.log(`Now browse to localhost:${PORT}/graphql`));
diff --git a/test/package.json b/test/package.json
new file mode 100644
index 0000000000..66e6a7e426
--- /dev/null
+++ b/test/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "graphql-mode-test-server",
+ "version": "1.0.0",
+ "description": "GraphQL server to test graphql-mode",
+ "main": "index.js",
+ "scripts": {
+ "start": "node index.js",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": {
+ "body-parser": "^1.15.2",
+ "express": "^4.15.0",
+ "express-graphql": "^0.6.3",
+ "graphql": "^0.9.1"
+ }
+}
diff --git a/test/schema.graphql b/test/schema.graphql
new file mode 100644
index 0000000000..6ae991f681
--- /dev/null
+++ b/test/schema.graphql
@@ -0,0 +1,3 @@
+type Query {
+ hello: String
+}
diff --git a/test/simple-query.graphql b/test/simple-query.graphql
new file mode 100644
index 0000000000..eb8f4922ab
--- /dev/null
+++ b/test/simple-query.graphql
@@ -0,0 +1,3 @@
+{
+ hello
+}