Skip to content

Commit

Permalink
Updated Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
myhendry committed Apr 3, 2018
1 parent ea480bf commit bedeb33
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 33 deletions.
33 changes: 1 addition & 32 deletions src/schema.js → src/graphql/resolvers/example.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
const { makeExecutableSchema } = require("graphql-tools");

const fetch = require("node-fetch");

const gql = String.raw;

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type Query {
myFavoriteArtists: [Artist]
}
type Artist @cacheControl(maxAge: 60) {
id: ID
name: String
image: String
twitterUrl: String
events: [Event]
}
type Event @cacheControl(maxAge: 60) {
name: String
image: String
startDateTime: String
}
`;

const resolvers = {
Query: {
myFavoriteArtists: (root, args, context) => {
Expand Down Expand Up @@ -67,12 +42,6 @@ const resolvers = {
}
};

// Required: Export the GraphQL.js schema object as "schema"
const schema = makeExecutableSchema({
typeDefs,
resolvers
});

const myFavoriteArtists = [
{
name: "Kansas",
Expand All @@ -88,4 +57,4 @@ const myFavoriteArtists = [
}
];

module.exports = { schema };
module.exports = { resolvers };
24 changes: 24 additions & 0 deletions src/graphql/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const gql = String.raw;

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type Query {
myFavoriteArtists: [Artist]
}
type Artist @cacheControl(maxAge: 60) {
id: ID
name: String
image: String
twitterUrl: String
events: [Event]
}
type Event @cacheControl(maxAge: 60) {
name: String
image: String
startDateTime: String
}
`;

module.exports = { typeDefs };
12 changes: 11 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ const express = require("express");
const { graphqlExpress, graphiqlExpress } = require("apollo-server-express");
const bodyParser = require("body-parser");
const { ApolloEngine } = require("apollo-engine");
const { makeExecutableSchema } = require("graphql-tools");

const { schema } = require("./schema");
const { typeDefs } = require("./graphql/schema");
const { resolvers } = require("./graphql/resolvers/example");
// const typeDefs = require("./graphql/schema");
// const { schema } = require("./graphql/schema");

const app = express();

Expand All @@ -19,6 +23,12 @@ if (!process.env.ENGINE_API_KEY) {
);
}

// Required: Export the GraphQL.js schema object as "schema"
const schema = makeExecutableSchema({
typeDefs,
resolvers
});

app.post(
"/graphql",
bodyParser.json(),
Expand Down
54 changes: 54 additions & 0 deletions yarn-error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Arguments:
/usr/local/bin/node /usr/local/Cellar/yarn/1.5.1_1/libexec/bin/yarn.js start

PATH:
/anaconda/bin:/Users/hendrylim/.rvm/gems/ruby-2.3.3/bin:/Users/hendrylim/.rvm/gems/ruby-2.3.3@global/bin:/Users/hendrylim/.rvm/rubies/ruby-2.3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/anaconda/bin:/Users/hendrylim/.rvm/gems/ruby-2.3.3/bin:/Users/hendrylim/.rvm/gems/ruby-2.3.3@global/bin:/Users/hendrylim/.rvm/rubies/ruby-2.3.3/bin:/Users/hendrylim/.rvm/bin:/Users/hendrylim/.rvm/bin

Yarn version:
1.5.1

Node version:
8.2.1

Platform:
darwin x64

npm manifest:
{
"private": true,
"main": "./src/server.js",
"scripts": {
"start": "node ./src/server.js"
},
"dependencies": {
"apollo-engine": "^1.0.1",
"apollo-server-express": "1.3.2",
"body-parser": "^1.17.1",
"express": "^4.15.2",
"graphql": "0.13.0",
"graphql-tools": "2.20.2",
"node-fetch": "^2.0.0"
}
}

yarn manifest:
No manifest

Lockfile:
No lockfile

Trace:
Error: Command failed.
Exit code: 1
Command: sh
Arguments: -c node ./src/server.js
Directory: /Users/hendrylim/react/ticketmaster-rest-api-wrapper
Output:

at ProcessTermError.MessageError (/usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:186:110)
at new ProcessTermError (/usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:226:113)
at ChildProcess.<anonymous> (/usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:30281:17)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:921:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

0 comments on commit bedeb33

Please sign in to comment.