Skip to content

Commit

Permalink
Test Queries
Browse files Browse the repository at this point in the history
  • Loading branch information
myhendry committed Apr 8, 2018
1 parent 5009297 commit 45e4898
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": ["equimper", "prettier"]
}
// {
// "extends": ["equimper", "prettier"]
// }
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.env
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"apollo-server-express": "1.3.2",
"body-parser": "^1.17.1",
"cross-env": "^5.1.4",
"dotenv": "^5.0.1",
"express": "^4.15.2",
"graphql": "0.13.0",
"graphql-date": "^1.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/config/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
PORT: process.env.PORT || 3000,
PORT: process.env.PORT || 5000,
DB_URL: "mongodb://localhost/gqltoy",
MONGO_URI: process.env.MONGO_URI,
GRAPHQL_PATH: "/graphql",
Expand Down
4 changes: 4 additions & 0 deletions src/graphql/resolvers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export const resolvers = {
});
})
);
},
getPerson: async (root, { id }, context) => {
const response = await fetch(`https://swapi.co/api/people/${id}/`);
return response.json();
}
},
Mutation: {
Expand Down
20 changes: 20 additions & 0 deletions src/graphql/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,32 @@ export const typeDefs = gql`
startDateTime: String
}
type Person {
name: String
height: String
mass: String
hair_color: String
skin_color: String
eye_color: String
birth_year: String
gender: String
films: [Film]
}
type Film {
title: String
episode_id: Int
director: String
producer: String
}
type Query {
getTweet(_id: ID!): Tweet
getTweets: [Tweet]
getUserTweets: [Tweet]
me: Me
myFavoriteArtists: [Artist]
getPerson(id: Int!): Person
}
type Mutation {
Expand Down
2 changes: 2 additions & 0 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { resolvers } from "./graphql/resolvers";

const app = express();

require("dotenv").config();

if (!process.env.TM_API_KEY) {
throw new Error(
"Please provide an API key for Ticketmaster in the environment variable TM_API_KEY."
Expand Down

0 comments on commit 45e4898

Please sign in to comment.