diff --git a/src/schema.js b/src/graphql/resolvers/example.js similarity index 69% rename from src/schema.js rename to src/graphql/resolvers/example.js index f70bfbb..725b8e8 100644 --- a/src/schema.js +++ b/src/graphql/resolvers/example.js @@ -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) => { @@ -67,12 +42,6 @@ const resolvers = { } }; -// Required: Export the GraphQL.js schema object as "schema" -const schema = makeExecutableSchema({ - typeDefs, - resolvers -}); - const myFavoriteArtists = [ { name: "Kansas", @@ -88,4 +57,4 @@ const myFavoriteArtists = [ } ]; -module.exports = { schema }; +module.exports = { resolvers }; diff --git a/src/graphql/schema.js b/src/graphql/schema.js new file mode 100644 index 0000000..f8d3447 --- /dev/null +++ b/src/graphql/schema.js @@ -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 }; diff --git a/src/server.js b/src/server.js index c2d055b..6fb2008 100644 --- a/src/server.js +++ b/src/server.js @@ -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(); @@ -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(), diff --git a/yarn-error.log b/yarn-error.log new file mode 100644 index 0000000..caee04b --- /dev/null +++ b/yarn-error.log @@ -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. (/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)