Uploaded image for project: 'S2Graph'
  1. S2Graph
  2. S2GRAPH-177

Add support for createServiceColumn/addVertex APIs on GraphQL.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Done
    • Major
    • Resolution: Done
    • None
    • None
    • None
    • None

    Description

      S2GRAPH-172 is good to start point for supporting GraphQL, but miss few important APIs for creating vertex schema and write

      Suggest adding following APIS.

      1. createServiceColumn

      mutation {
        createServiceColumn(
          serviceName:wiki, 
          columnName:"user", 
          columnType: string, 
          props: [
            { name: "name", dataType:string, defaultValue: "-" },
            { name: "age", dataType:int, defaultValue: "-1" },
            { name: "gender", dataType:string, defaultValue: "-"} 
          ]
        ) {
          
          isSuccess
        }
      }
      
      

      the user may check if 'user' serviceColumn has been created correctly.

      query {
        Services(name: wiki) {
          serviceColumns {
            name,
            props {
              id,
              name,
              dataType
            }
          }
        }
      }
      

      note that serviceColumn is nested under service. also, properties on 'user' vertex can be suggested through graphiQL according to the schema.

      2. addVertex

      mutation {
        addVertex(
          wiki:{
            user:{
              id:"steamshon",
              props:{
                name: "aha",
                age: 30,
                gender: "M"
              }
            }
          }
        ) {
          isSuccess
        }
      }
      

      note that props can be suggested through graphiQL.

      3. addVertexBulk

      mutation { 
        addVertexBulk(
          serviceName: wiki,
          columnName: user,
          id: "steamshon",
          timestamp: 1,
          props: {
            name: "aha",
            age: 30,
            gender: "M"
          }
        ) {
          isSuccess
        }
      }
      

      Not required, but simple helper for bulk load use cases.

      Once the mutation is done, vertex query can be executed as follow.

      query {
        wiki: {
          user(id: "steamshon") {
            name,
            age
          }
        }
      }
      

      One thing needs more discussion is the case with vertex and edge in the query.

      query {
        wiki: {
          user(id: "steamshon") {
            friends {
              to
            }
            name,
            age
          }
        }
      }
      

      above query means return vertex id steamshon with its name, age property on it and return all friends' id(in this case to means vertex id). this requires one getVertex and getEdges call to the backend.

      query {
        wiki: {
          user(id: "steamshon") {
            name,
            age,
            friends {
              to {
                id,
                name
              }
              post {
                to {
                  id
                }
              }
            }
          }
        }
      }
      

      the last query need to return steamshon's friends's name, age property which is vertex property. This requires one getEdges call and # of edges return times getVerex call to the backend.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              steamshon Do Yung Yoon
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 168h
                  168h
                  Remaining:
                  Remaining Estimate - 168h
                  168h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified