Last active
September 10, 2019 20:59
-
-
Save vincentntang/fa5c35dde33c8d2ad665c3df73eca781 to your computer and use it in GitHub Desktop.
Example of a graphql setup (Resolver - handles functions, query requests data, graphql.json is the return, schema.graphql is what you can traverse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"jobs": [ | |
{ | |
"id": "rJKAbDd_z", | |
"title": "Frontend Developer", | |
"company": { | |
"id": "HJRa-DOuG", | |
"name": "Facegle", | |
"description": "We are a startup on a mission to disrupt social search engines. Think Facebook meet Google." | |
}, | |
"description": "We are looking for a Frontend Developer familiar with React." | |
}, | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
jobs { | |
id | |
title | |
company { | |
id | |
name | |
description | |
} | |
description | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const db = require('./db'); | |
const Query = { | |
jobs: () => db.jobs.list() | |
}; | |
const Job = { | |
company: (job) => db.companies.get(job.companyId) | |
} | |
module.exports = { Query, Job}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
jobs: [Job] | |
} | |
type Company { | |
id: ID! | |
name: String | |
description: String | |
} | |
type Job { | |
id: ID! | |
title: String | |
company: Company | |
description: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment