Skip to content
Permalink
Browse files

02-Apollo Server: Type Definitions

  • Loading branch information...
rwieruch committed Oct 25, 2018
1 parent b6468a8 commit 469080f810a0049442f02393fae746cebc391cc0
Showing with 23 additions and 3 deletions.
  1. +23 −3 server/src/index.js
@@ -9,20 +9,40 @@ app.use(cors());

const schema = gql`
type Query {
users: [User!]
me: User
user(id: ID!): User
}
type User {
id: ID!
username: String!
}
`;

let users = {
1: {
id: '1',
username: 'Robin Wieruch',
},
2: {
id: '2',
username: 'Dave Davids',
},
};

const me = users[1];

const resolvers = {
Query: {
users: () => {
return Object.values(users);
},
user: (parent, { id }) => {
return users[id];
},
me: () => {
return {
username: 'Robin Wieruch',
};
return me;
},
},
};

0 comments on commit 469080f

Please sign in to comment.
You can’t perform that action at this time.