Schema design for modifying a pathway - megabit-labs/pathways GitHub Wiki

There are two operations for Pathways CRUD,

  1. createUpdatePathway: Create new pathway, steps or update them. The query updates all the fields of the path and steps. It also deletes previous relationships between step and content before updating it with a new content relationship.
  2. deletePathway: Delete steps or whole pathway. Passing true for whole argument deletes all the steps and then the path. Note that without whole: true, the Pathway is not deleted even if it has no steps.

After Seeding the database you can try out the following queries. Remember to change the PATHWAY_ID and STEP_ID.

Create pathway and add steps

mutation {
  createUpdatePathway(
    id: "",
    name: "NoMoreHoho",
    steps: [{
      id: "",
			time: 5,
      name: "Santa",
      index: 0,
      isPathway: true,
      typeId: "<PATHWAY_ID>",
    }],
  ) {
    status,
    message
  }
}

Delete existing steps

Query the db to get the id for the newly created pathway and step and then use it in the following query.

mutation {
  deletePathway(
    id: "<PATHWAY_ID>",
    steps: [{
      id: "<STEP_ID>",
      time: 5,
      name: "Santa",
      index: 0,
      isPathway: true,
      typeId: "",
    }],
    whole: false
  ) {
    status,
    message
  }
}
⚠️ **GitHub.com Fallback** ⚠️