mirror of
https://github.com/Telecominfraproject/wlan-cloud-graphql-gw.git
synced 2025-10-29 17:52:24 +00:00
init
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
1312
package-lock.json
generated
Normal file
1312
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
package.json
Normal file
23
package.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "tip-wlan-graphql-apollo",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"apollo-server": "^2.11.0",
|
||||
"graphql": "^14.6.0"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://sean_macfarlane@bitbucket.org/connectustechnologies/tip-wlan-graphql-apollo.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"homepage": "https://bitbucket.org/connectustechnologies/tip-wlan-graphql-apollo#readme"
|
||||
}
|
||||
24
src/index.js
Normal file
24
src/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const { ApolloServer, gql } = require("apollo-server");
|
||||
|
||||
const typeDefs = require("./schema");
|
||||
const resolvers = require("./resolvers");
|
||||
|
||||
const books = [
|
||||
{
|
||||
title: "Harry Potter and the Chamber of Secrets",
|
||||
author: "J.K. Rowling"
|
||||
},
|
||||
{
|
||||
title: "Jurassic Park",
|
||||
author: "Michael Crichton"
|
||||
}
|
||||
];
|
||||
|
||||
// The ApolloServer constructor requires two parameters: your schema
|
||||
// definition and your set of resolvers.
|
||||
const server = new ApolloServer({ typeDefs, resolvers });
|
||||
|
||||
// The `listen` method launches a web server.
|
||||
server.listen().then(({ url }) => {
|
||||
console.log(`🚀 Server ready at ${url}`);
|
||||
});
|
||||
9
src/resolvers.js
Normal file
9
src/resolvers.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Resolvers define the technique for fetching the types defined in the
|
||||
// schema. This resolver retrieves books from the "books" array above.
|
||||
const resolvers = {
|
||||
Query: {
|
||||
books: () => books
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = resolvers;
|
||||
21
src/schema.js
Normal file
21
src/schema.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// A schema is a collection of type definitions (hence "typeDefs")
|
||||
// that together define the "shape" of queries that are executed against
|
||||
// your data.
|
||||
const typeDefs = gql`
|
||||
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.
|
||||
|
||||
# This "Book" type defines the queryable fields for every book in our data source.
|
||||
type Book {
|
||||
title: String
|
||||
author: String
|
||||
}
|
||||
|
||||
# The "Query" type is special: it lists all of the available queries that
|
||||
# clients can execute, along with the return type for each. In this
|
||||
# case, the "books" query returns an array of zero or more Books (defined above).
|
||||
type Query {
|
||||
books: [Book]
|
||||
}
|
||||
`;
|
||||
|
||||
module.exports = typeDefs;
|
||||
Reference in New Issue
Block a user