Skip to content

Instantly share code, notes, and snippets.

@vincentntang
Last active September 10, 2019 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincentntang/fa5c35dde33c8d2ad665c3df73eca781 to your computer and use it in GitHub Desktop.
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
{
"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."
},
]
}
}
{
jobs {
id
title
company {
id
name
description
}
description
}
}
const db = require('./db');
const Query = {
jobs: () => db.jobs.list()
};
const Job = {
company: (job) => db.companies.get(job.companyId)
}
module.exports = { Query, Job};
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