Created
December 29, 2018 19:31
-
-
Save dammyng/6c12015fd8a9c724b7070a73997fcffd to your computer and use it in GitHub Desktop.
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
var express = require('express') | |
const { ApolloServer,gql } = require('apollo-server-express'); | |
const typeDefs = gql` | |
type Query { | |
greet: String, | |
users :[User], | |
musers:[User] | |
} | |
type User { | |
id:String, | |
email:String, | |
password:String, | |
companyId:String | |
}` | |
const resolvers = { | |
Query: { | |
greet: () => { | |
return "Hello from GraphQl side" | |
}, | |
users:()=>{ | |
return fetchData() | |
} | |
}, | |
} | |
const app = express(); | |
const SERVER = new ApolloServer({ | |
typeDefs: typeDefs, | |
resolvers: resolvers, | |
playground: { | |
endpoint: `http://localhost:3600/graphql`, | |
settings: { | |
'editor.theme': 'light' | |
} | |
} | |
}); | |
SERVER.applyMiddleware({ | |
app: app | |
}); | |
app.listen(3600 , ()=> {console.log("App started")}) | |
var fetchData = ()=>{ | |
var fakeUsers = [ | |
{ | |
"id": "BJrp-DudG", | |
"email": "alice@facegle.io", | |
"password": "alice123", | |
"companyId": "HJRa-DOuG" | |
}, | |
{ | |
"id": "ry9pbwdOz", | |
"email": "bob@goobook.co", | |
"password": "bob123", | |
"companyId": "SJV0-wdOM" | |
} | |
] | |
return fakeUsers; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment