Skip to content

Commit

Permalink
Step 2.1: Update Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
srtucker22 authored and Simon Tucker committed Aug 26, 2018
1 parent e780549 commit ae273fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
35 changes: 35 additions & 0 deletions server/data/schema.js
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;
10 changes: 2 additions & 8 deletions server/index.js
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}`));

0 comments on commit ae273fb

Please sign in to comment.