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

Changing query more intuitively by using `columnName` instead of `from/to` in label field name

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Done
    • Major
    • Resolution: Done
    • None
    • None
    • s2graphql

    Description

      Changing query more intuitively by using `columnName` instead of `from/to` in label field name

      When fetching a Label Associated with a ServiceColumn, `from/to` Is used as the Label field.
      This indirectly represents the `source/target Column` in the Label.

      You can also query the next step based on the corresponding `from/to`.

      ColumnName defined in the Label schema to create a more intuitive query than using `from/to`.

      For example, suppose you have the following Services, ServiceColumns, and Label.

      service = Service(name: kakao)
      userColumn = ServiceColumn(serviceName: kakao, name: user)
      movieColumn = ServiceColumn(serviceName: kakao, name: movie)
      Label(name: like, sourceServiceColumn: userColumn, targetServiceColumn: movieColumn)
      

      Let's take an example of a query that comes from a user who likes movies that user 'daewon' likes.

      As is

      query {
        kakao {
          user(id: "daewon") {
            like(direction: out) { # By Label(like) shcmea, direction is fixed in `out`
              score
              to { # `to` Represents the targetServiceColumn (movie) of `like` label.
                id
                like(direction: in) { # By Label(like) shcmea, direction is fixed in `in`
                  score
                  from { # In the case of the in direction, it is confused because the directions `from` and `to` are relatively determined.
                    id
                    age
                  }
                }
              }
            }
          }
        }
      }
      
      

      To be

      query {
        kakao {  
          user(id: "daewon") {      
            like { # For a Label(like) started with serviceColumn(user), the direction is fixed to `out`.
              score            
              movie { 
                id         
                like { # For a Label(like) started with serviceColumn(movie), the direction is fixed to `in`.
                  score              
                  user { 
                    id
                    age
                  }      
                }  
              }
            }
          }
        }
      }
      

      As you can see in the example above, we can know in advance how to query `like` label according to the starting column(user/movie), and also use field name instead of `from/to` to use columnName.

      Attachments

        Issue Links

          Activity

            People

              daewon Daewon Jeong
              daewon Daewon Jeong
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: