-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e780549
commit ae273fb
Showing
2 changed files
with
37 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { gql } from 'apollo-server'; | ||
|
||
export const typeDefs = gql` | ||
# declare custom scalars | ||
scalar Date | ||
# a group chat entity | ||
type Group { | ||
id: Int! # unique id for the group | ||
name: String # name of the group | ||
users: [User]! # users in the group | ||
messages: [Message] # messages sent to the group | ||
} | ||
# a user -- keep type really simple for now | ||
type User { | ||
id: Int! # unique id for the user | ||
email: String! # we will also require a unique email per user | ||
username: String # this is the name we'll show other users | ||
messages: [Message] # messages sent by user | ||
groups: [Group] # groups the user belongs to | ||
friends: [User] # user's friends/contacts | ||
} | ||
# a message sent from a user to a group | ||
type Message { | ||
id: Int! # unique id for message | ||
to: Group! # group message was sent in | ||
from: User! # user who sent the message | ||
text: String! # message text | ||
createdAt: Date! # when message was created | ||
} | ||
`; | ||
|
||
export default typeDefs; |
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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
import { ApolloServer, gql } from 'apollo-server'; | ||
import { ApolloServer } from 'apollo-server'; | ||
import { typeDefs } from './data/schema'; | ||
|
||
const PORT = 8080; | ||
|
||
// basic schema | ||
const typeDefs = gql` | ||
type Query { | ||
testString: String | ||
} | ||
`; | ||
|
||
const server = new ApolloServer({ typeDefs, mocks: true }); | ||
|
||
server.listen({ port: PORT }).then(({ url }) => console.log(`🚀 Server ready at ${url}`)); |