~bigbes/sr-ht-dolt

ref: bd2d8a3680e62716440ea0165d2271d79f9d526e sr-ht-dolt/graph/schema.graphqls -rw-r--r-- 5.8 KiB
bd2d8a36 — Eugene Blikh doltsrht: serve /query and the api-meta.json beside it 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# dolt.sr.ht — the read schema.
#
# There are no mutations here, and the reason is the same one spec.sr.ht gives:
# a type federated into api.sr.ht is a consumed contract, expensive to churn, so
# only what has settled is published. Creating, renaming and deleting a database
# each move a metadata row and an on-disk store together, and that pairing is
# young; it stays behind the web UI until it is not.
#
# Rows and diffs are absent for a different reason. They exist on /mcp, where a
# read that had to be clipped says so in its own answer — a shape this schema
# would have to reproduce field by field to stay honest. Until it does, a client
# that wants table contents should ask /mcp, and this schema stops at the
# structure: what databases exist, what branches and commits they carry, and
# what tables live at a ref.
#
# Everything below is read through the same db/ store and browse/ session the
# web pages and the MCP tools use, so the three surfaces cannot disagree about
# what a database is.

"""
An RFC-3339 timestamp.
"""
scalar Time

"""
An opaque pagination cursor. Pass it back into the same field to fetch the next
page; it is null when there are no further results.
"""
scalar Cursor

"""
Who may see a database, and how it is listed.

PUBLIC is listed to everyone including anonymous callers. UNLISTED is reachable
by direct address but never appears in a listing to a stranger. PRIVATE is
neither: to a caller who may not see it, it does not exist — this schema answers
null rather than an authorization error, exactly as the web UI answers "no such
database" rather than "forbidden".
"""
enum Visibility {
  PUBLIC
  UNLISTED
  PRIVATE
}

"""
An ACL grant: read-only (browse and clone) or read-write (and push).
"""
enum AccessMode {
  RO
  RW
}

"""
A SourceHut account, mirrored from meta.sr.ht.
"""
type User {
  """
  The username with no leading "~". This is the name that addresses the account
  in `database(owner:)` and in a clone URL's path.
  """
  username: String!

  """
  The username with its leading "~", as SourceHut writes it in prose and in the
  web UI.
  """
  canonicalName: String!
}

"""
A hosted Dolt database: one metadata row and one bare chunk store.
"""
type Database {
  id: Int!
  name: String!
  owner: User!

  """
  The description shown in listings. Empty rather than null when unset: a
  companion of a git repository mirrors that repository's description, and "no
  description" and "the empty description" are the same state here.
  """
  description: String!
  visibility: Visibility!
  created: Time!
  updated: Time!

  """
  The branch a reader lands on: "main" when it exists, else the first branch by
  name. Null for a database nothing has been pushed to yet — a store with no
  commits has no branches, which is a state and not a failure.
  """
  defaultBranch: String

  """
  Every branch, the default one first and the rest by name. Empty for a database
  nothing has been pushed to.
  """
  branches: [Branch!]!

  """
  The commit log of `ref`, newest first. `ref` is a branch name or a commit
  hash, defaulting to `defaultBranch`; `from` continues a previous page from the
  hash it returned as `cursor`.
  """
  log(ref: String, from: Cursor, limit: Int): CommitCursor!

  """
  The tables of the committed root at `ref` (a branch name or a commit hash,
  defaulting to `defaultBranch`), each with its columns and row count.
  """
  tables(ref: String): [Table!]!

  """
  Who else may read or write this database. Owner-only: to anybody else it is
  the empty list, because the collaborator list of a database you do not own is
  not yours to enumerate.
  """
  acl: [ACLEntry!]!
}

"""
A branch and the commit it points at.
"""
type Branch {
  name: String!
  head: String!
}

"""
One commit of a database's history.
"""
type Commit {
  hash: String!
  author: String!
  email: String!
  date: Time!
  message: String!
  parents: [String!]!
}

"""
A column of a table, as the stored schema declares it.
"""
type Column {
  name: String!
  type: String!
  primaryKey: Boolean!
  nullable: Boolean!
}

"""
A table at a ref: its schema and how many rows it holds there.
"""
type Table {
  name: String!
  columns: [Column!]!
  rowCount: Int!
}

"""
An access grant on a database.
"""
type ACLEntry {
  user: User!
  mode: AccessMode!
}

"""
How a listing is paged. It is git.sr.ht's `Filter` minus `search`: nothing here
searches yet, and declaring a field this schema would ignore is a worse answer
than not declaring it.
"""
input Filter {
  """
  How many results one page holds, capped at 100. It travels in the cursor the
  page returns, so it is given once and kept for the rest of the walk.
  """
  count: Int = 25
}

type DatabaseCursor {
  results: [Database!]!
  cursor: Cursor
}

type CommitCursor {
  results: [Commit!]!
  cursor: Cursor
}

type Query {
  """
  The caller, or null for an anonymous one. Anonymous is a normal caller on this
  schema — it reads what an anonymous visitor reads — so a null here is an
  answer and not an error.
  """
  me: User

  """
  Every database the caller may be shown, newest first, across all owners.

  This is the listing rule and not the read rule: PUBLIC to everyone, plus
  whatever the caller owns or holds an ACL entry on. An UNLISTED database of
  somebody else is absent here and still readable through `database`.
  """
  databases(cursor: Cursor, filter: Filter): DatabaseCursor!

  """
  One owner's databases, under the same listing rule as `databases`. `owner`
  carries no leading "~".
  """
  databasesByOwner(owner: String!, cursor: Cursor, filter: Filter): DatabaseCursor!

  """
  One database by owner and name, neither carrying a leading "~". Null when
  there is no such database *or* when the caller may not see it — the two are
  deliberately one answer, so that a PRIVATE database cannot be discovered by
  the shape of the refusal.
  """
  database(owner: String!, name: String!): Database
}