This solution is in response to Modern Health's Technical Challenge using GRAPHQL, a non-rest implementation.
- Python3
- Django2
- GraphQL
- React
We would like for you to create a backend for a simple tool that will enable the creation of Programs, Weeks, and Pages.
Programs have 2 or more weeks
Programs have the following fields
- Name
- Description
- Image
- Category
Weeks have 2 or more pages
Pages have the following fields
- audio
- video
- article
- form
- question
The Program editor should follow CRUD operations for Programs, Weeks, and Pages.
Model should allow tracking of different pages, weeks, and programs, accomplished by the User.
Instructions (If you run into issues, email me at dgolman@vt.edu)
1) git clone https://github.com/aircert/modern_health_django_graphql.git
2) cd modern_health_django_graphql
3) make
Click - http://localhost:8000/graphql
# Create page
mutation {
pageCreate(newPage: {
name: "Page 6",
video: "http://google.com/video",
audio: "http://google.com/audio",
form: "http://google.com/form",
question: "http://google.com/question",
article: "http://google.com/article"
}) {
page {
id
complete
}
}
}
# Create Week
mutation {
weekCreate(newWeek: {
pages: [6, 5],
name: "Week 4"
}) {
week {
id
name
pages {
name
}
}
}
}
# Delete Program
mutation {
programDelete(id: 2) {
program {
id
}
}
}
# Create Program
mutation {
programCreate(newProgram: {
name: "Mindful Communication",
description: "Minfully communicate with coworkers",
weeks: [3,4],
progress: 0
}) {
program {
id
name
description
progress
image
weeks {
id
name
pages {
id
name
complete
}
}
}
errors {
messages
field
}
}
}
# Get All Weeks
query {
allWeeks {
id
name
pages {
name
complete
}
}
}
# Get all pages
query {
allPages {
id
name
}
}
# Get all programs, weeks, and pages for each
query {
allPrograms {
id
name
description
progress
image
weeks {
id
name
pages {
id
name
complete
}
}
}
}
# Update a program by weeks
mutation {
programUpdate(newProgram: {id: 2, weeks: [1,2,3,4]}) {
program {
id
weeks {
id
}
}
}
}
# Update a pages progress to complete
mutation {
pageUpdate(newPage: {id: 1, complete: true}) {
page {
id
complete
dateModified
dateCreated
}
}
}
- Navigate to http://localhost:8000