Seeding the database - megabit-labs/pathways GitHub Wiki

Get the server up and running, go to the GraphQL playground (probably at 0.0.0.0:3003, if you did not change any settings, and run the following queries to seed the database. You will need apoc to run these queries, if you are using docker-compose it will be included. However if you are using neo4j locally, follow this answer to install apoc.

Logging In

Request the code from GitHub and use the code to call the GitHub Auth mutation.

mutation {
  GithubAuth(code: "ea7edcba72284ba9abb1") {
    token
    message
    status
  }
}

Creating/Updating Content

Create a Content with given id, title and content. The author is set to the currently logged in user.


mutation {
  createUpdateContent(
    id: "Content_1"
    title: "Git Init"
    content: "Initialise a repository using the git init command.
    Git init creates a .git folder inside the directory you call it in. 
    You can now track files in this directory. "
  ) {
    message
    status
  }

}

Create Update Pathways

Using the content we just created, create a Pathway with given id, name, description, tags and steps. The author is set to the currently logged in user.

mutation {
  createUpdatePathway(
    id: "Pathway_1"
    name: "Learning Git"
    description: "Learn to use git commands step-by-step and become a ninja"
    tags: ["git", "command-line", "version-conrol"]
    steps: [
      {
        stepType:CONTENT_STEP,
        id:"Step_1",
        name:"Initialising a Repository"
        time:15
        typeId:"Content_1"
        index:0
      },
      {
        stepType:CONTENT_STEP,
        id:"Step_2",
        name:"Adding files to the repository"
        time:15
        typeId:"Content_2"
        index:1
      }
    ]
  ) {
    message
    status
  }
}

Create a Pathway referring to another Pathway

Above, we saw how to create steps that include some content. But as we know, steps can also contain another Pathway. Let's see how that's done. Create a new Pathway with a single step.

mutation {
  createUpdatePathway(
    id: "Pathway_2"
    name: "Important Tools Every Developer Should Know"
    description: "Learn how to use these indispensable tools you must have in your developer toolkit. "
    tags: ["devops", "bash", "linux"]
    steps: [
      {
        stepType:PATHWAY_STEP,
        id:"Step_3",
        name:"Learn how to use Git"
        time:15
        typeId:"Pathway_1"
        index:0
      },
    ]
  ) {
    message
    status
  }
}