public

Examples of graphql (queries)

Note: that all queries present here can be ran in your own school. For this you must login with an admin role and access the following route https://((DOMAIN))/graphiql. Depending on our role the tables permissions may differ.

Simple queries to get info

query getUserInfo($name: String!) {
  user(where: {login: {_eq: $name}}) {
    profile
    login
    attrs
    auditRatio
    campus
    createdAt
    totalDown
    totalUp
    updatedAt
  }
}

Query variable:

{"name": "Joao"}

query bannedUsers($name: String!) {
  record(where: {user: {login: {_eq: $name}}}) {
    authorLogin
    banEndAt
    createdAt
    message
  }
}

Query variable:

{"name": "Joao"}

query getGroupInfo($object: String!) {
  group(where: {object: {name: {_eq: $object}}}) {
    captainLogin
    path
    status
    members {
      userLogin
    }
  }
}

Query variable:

{"path": "/madere/div-01/go-reloaded"}

query eventsByCampus($campus: String!) {
  event(where: {campus: {_eq: $campus}}) {
    object {
      name
    }
    parent {
      path
      object {
        name
      }
      createdAt
      endAt
      path
    }
  }
}

Query variable:

{ "campus": "madere" }

query usersEvent($campus: String!, $path: String!) {
  event_user(where: {event: {path: {_eq: $path}, _and: {campus: {_eq: $campus}}}}) {
    userAuditRatio
    userLogin
    event {
      path
      object {
        name
      }
    }
  }
}

Query variable:

{"campus": "madera", "path": "/madere/div-01/piscine-js"}
query usersEvent($campus: String!, $objectType: String!) {
  event_user(where: {event: {object: {type: {_eq: $objectType}}, _and: {campus: {_eq: $campus}}}}) {
    userAuditRatio
    userLogin
    event {
      path
      object {
        name
      }
    }
  }
}

Query variable:

{"campus": "pyc", "objectType": "raid"}

query xp($name: String!) {
  xp(where: {user: {login: {_eq: $name}}}) {
    user {
      login
    }
    amount
  }
}

Query variable:

{"name": "Joao"}
query eventXp($userName: String!, $objectName: String!) {
  xp_by_path(where: {user: {login: {_eq: $userName}}, _and: {object: {name: {_eq: $objectName}}}}) {
    path
    user {
      login
    }
    event {
      path
    }
    object {
      name
    }
    amount
  }
}

Query variable:

{"userName": "Joao", "objectName": "ascii-art"}

query getGameInfo($name: String!) {
  toad_result_view(where: {user: {login: {_eq: $name}}}) {
    user {
      login
    }
    attempts
    allowedAttempts
     score
    path
    games
  }
}

Query variables:

{"name": "Joao"}

query getProgress($name: String!, $path: String!) {
  progress(where: {user: {login: {_eq: $name}}, _and: {path: {_eq: $path}}}) {
    path
    grade
    isDone
    campus
    group {
      captainLogin
      members {
        user {
          login
        }
      }
    }
  }
}

query variable:

{"name": "Joao", "path": "/madere/piscine-go/exam-01" }