Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema list API #1624

Closed
nasdf opened this issue Jul 11, 2023 · 0 comments · Fixed by #1625
Closed

Schema list API #1624

nasdf opened this issue Jul 11, 2023 · 0 comments · Fixed by #1625
Assignees
Labels
area/api Related to the external API component feature New feature or request

Comments

@nasdf
Copy link
Member

nasdf commented Jul 11, 2023

We could use an API for returning user created schemas from DefraDB.
This will make it easier for users to export and update schemas.
The API should return all collections and fields excluding auto generated ones.

@nasdf nasdf added feature New feature or request area/api Related to the external API component labels Jul 11, 2023
@nasdf nasdf self-assigned this Jul 11, 2023
@nasdf nasdf mentioned this issue Jul 11, 2023
4 tasks
nasdf added a commit that referenced this issue Jul 12, 2023
## Relevant issue(s)

Resolves #1624 

## Description

This PR adds an API for listing schemas.
The schema API routes have also been simplified to be more RESTful.

### HTTP

`curl http://localhost:9181/api/v0/schema`

#### Output

```
{
  "data": {
    "collections": [
      {
        "name": "User",
        "id": "bafkreibpnvkvjqvg4skzlijka5xe63zeu74ivcjwd76q7yi65jdhwqhske",
        "fields": [
          {
            "id": "1",
            "name": "age",
            "kind": "Int"
          },
          {
            "id": "2",
            "name": "name",
            "kind": "String"
          },
          {
            "id": "3",
            "name": "points",
            "kind": "Float"
          },
          {
            "id": "4",
            "name": "verified",
            "kind": "Boolean"
          }
        ]
      }
    ],
    "result": "success"
  }
}
```

### CLI

`defradb client schema list`

#### Output

```
type User {
    name: String 
    age: Int 
    verified: Boolean 
    points: Float
}
```

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] I made sure the pull request title adheres to the conventional
commit style (the subset used in the project can be found in
[tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)).
- [x] I made sure to discuss its limitations such as threats to
validity, vulnerability to mistake and misuse, robustness to
invalidation of assumptions, resource requirements, ...

## How has this been tested?

Automated test + manual testing

Specify the platform(s) on which this was tested:
- MacOS
shahzadlone pushed a commit to shahzadlone/defradb that referenced this issue Feb 23, 2024
## Relevant issue(s)

Resolves sourcenetwork#1624 

## Description

This PR adds an API for listing schemas.
The schema API routes have also been simplified to be more RESTful.

### HTTP

`curl http://localhost:9181/api/v0/schema`

#### Output

```
{
  "data": {
    "collections": [
      {
        "name": "User",
        "id": "bafkreibpnvkvjqvg4skzlijka5xe63zeu74ivcjwd76q7yi65jdhwqhske",
        "fields": [
          {
            "id": "1",
            "name": "age",
            "kind": "Int"
          },
          {
            "id": "2",
            "name": "name",
            "kind": "String"
          },
          {
            "id": "3",
            "name": "points",
            "kind": "Float"
          },
          {
            "id": "4",
            "name": "verified",
            "kind": "Boolean"
          }
        ]
      }
    ],
    "result": "success"
  }
}
```

### CLI

`defradb client schema list`

#### Output

```
type User {
    name: String 
    age: Int 
    verified: Boolean 
    points: Float
}
```

## Tasks

- [x] I made sure the code is well commented, particularly
hard-to-understand areas.
- [x] I made sure the repository-held documentation is changed
accordingly.
- [x] I made sure the pull request title adheres to the conventional
commit style (the subset used in the project can be found in
[tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)).
- [x] I made sure to discuss its limitations such as threats to
validity, vulnerability to mistake and misuse, robustness to
invalidation of assumptions, resource requirements, ...

## How has this been tested?

Automated test + manual testing

Specify the platform(s) on which this was tested:
- MacOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Related to the external API component feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant