home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

23 rows where author_association = "OWNER", issue = 1427293909 and user = 9599 sorted by updated_at descending

✖
✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 1

  • simonw · 23 ✖

issue 1

  • API explorer tool · 23 ✖

author_association 1

  • OWNER · 23 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1313125870 https://github.com/simonw/datasette/issues/1871#issuecomment-1313125870 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5ORLXu simonw 9599 2022-11-14T05:42:50Z 2022-11-14T05:42:50Z OWNER

Demo: https://latest-1-0-dev.datasette.io/-/api#path=%2Ffixtures%2Ffacetable%2F-%2Fdrop&json=%7B%22confirm%22%3A+true%7D&method=POST

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1313097057 https://github.com/simonw/datasette/issues/1871#issuecomment-1313097057 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OREVh simonw 9599 2022-11-14T04:59:28Z 2022-11-14T04:59:28Z OWNER

In playing with the API explorer just now I realized it's way too easy to accidentally drop a table using it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1313072900 https://github.com/simonw/datasette/issues/1871#issuecomment-1313072900 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OQ-cE simonw 9599 2022-11-14T04:15:50Z 2022-11-14T04:15:50Z OWNER

For the example links - I'm going to have these at the bottom of the page so you don't have to scroll past them.

Ideally these would take the user's permissions into account. This could make the page expensive to load, but I'm going to risk it for the moment.

Something like this then:

  • data
  • /data/-/create - create table
  • /data/table1/-/insert - insert into table1
  • /data/table1/-/drop - drop table1

I won't bother with per-row demo links (for update and delete) because there could be thousands of them for each table.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1313062699 https://github.com/simonw/datasette/issues/1871#issuecomment-1313062699 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OQ78r simonw 9599 2022-11-14T04:03:29Z 2022-11-14T04:12:41Z OWNER

Two things left before I close this issue:

  • [x] I want to preserve the state of the forms in the URL - probably after a #
  • [ ] Instead of hard-coding the current examples, I want to provide a list of links which populate the forms
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1312822353 https://github.com/simonw/datasette/issues/1871#issuecomment-1312822353 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OQBRR simonw 9599 2022-11-13T21:07:40Z 2022-11-13T21:07:40Z OWNER

I'm going to need extra code to toggle POST closed when GET opens and vice-versa.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1312821031 https://github.com/simonw/datasette/issues/1871#issuecomment-1312821031 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OQA8n simonw 9599 2022-11-13T21:02:06Z 2022-11-13T21:03:11Z OWNER

Actually no, I'm going to add a class of details-menu to the other details elements that SHOULD be closed. That way custom templates using <details> won't close in a surprising way.

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1312816451 https://github.com/simonw/datasette/issues/1871#issuecomment-1312816451 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OP_1D simonw 9599 2022-11-13T20:39:26Z 2022-11-13T20:39:34Z OWNER

I'm going to add a special no-auto-close class to these and teach that code not to close them.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1312816292 https://github.com/simonw/datasette/issues/1871#issuecomment-1312816292 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5OP_yk simonw 9599 2022-11-13T20:38:42Z 2022-11-13T20:38:42Z OWNER

The current API explorer uses details/summary elements for the GET and POST dialogs.

I only want one of these to be open at a time, to reflect that you can make either a GET or a POST.

I just noticed that clicking anywhere else on the page closes both elements, which isn't what I want to happen. Turns out that's because of this code I added as part of Datasette's menu implementation!

https://github.com/simonw/datasette/blob/9f54f00a50a4d950cfd69a0ff3526ae82c858826/datasette/templates/_close_open_menus.html#L2-L15

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1302815105 https://github.com/simonw/datasette/issues/1871#issuecomment-1302815105 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5Np2GB simonw 9599 2022-11-04T00:17:23Z 2022-11-04T00:17:23Z OWNER

I'll probably enhance it a bit more though, I want to provide a UI that lists all the tables you can explore and lets you click to pre-fill the forms with them.

Though at that point what should I do about the other endpoints? Probably list those too. Gets a bit complex, especially with the row-level update and delete endpoints.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1302814693 https://github.com/simonw/datasette/issues/1871#issuecomment-1302814693 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5Np1_l simonw 9599 2022-11-04T00:16:36Z 2022-11-04T00:16:36Z OWNER

I can close this issue once I fix it so it no longer hard-codes a potentially invalid example endpoint:

https://github.com/simonw/datasette/blob/bcc781f4c50a8870e3389c4e60acb625c34b0317/datasette/templates/api_explorer.html#L24-L26

https://github.com/simonw/datasette/blob/bcc781f4c50a8870e3389c4e60acb625c34b0317/datasette/templates/api_explorer.html#L34-L35

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299607082 https://github.com/simonw/datasette/issues/1871#issuecomment-1299607082 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5Ndm4q simonw 9599 2022-11-02T05:45:31Z 2022-11-02T05:45:31Z OWNER

I'm going to add a link to the Datasette API docs for the current running version of Datasette, e.g. to https://docs.datasette.io/en/0.63/json_api.html

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299600257 https://github.com/simonw/datasette/issues/1871#issuecomment-1299600257 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NdlOB simonw 9599 2022-11-02T05:36:40Z 2022-11-02T05:36:40Z OWNER

The API Explorer should definitely link to the /-/create-token page for users who have permission though.

And it should probably go in the Datasette application menu?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299599461 https://github.com/simonw/datasette/issues/1871#issuecomment-1299599461 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NdlBl simonw 9599 2022-11-02T05:35:36Z 2022-11-02T05:36:15Z OWNER

Here's a slightly wild idea: what if there was a button on /-/api that you could click to turn on "API explorer mode" for the rest of the Datasette interface - which sets a cookie, and that cookie means you then see "API explorer" links in all sorts of other relevant places in the Datasette UI (maybe tucked away in cog menus).

Only reason I don't want to show these to everyone is that I don't think this is a very user-friendly feature: if you don't know what an API is I don't want to expose you to it unnecessarily.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299598570 https://github.com/simonw/datasette/issues/1871#issuecomment-1299598570 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5Ndkzq simonw 9599 2022-11-02T05:34:28Z 2022-11-02T05:34:28Z OWNER

This is pretty useful now. Two features I still want to add:

  • The ability to link to the API explorer such that the form is pre-filled with material from the URL. Need to guard against clickjacking first though, so no-one can link to it in an invisible iframe and trick the user into hitting POST.
  • Some kind of list of endpoints so people can click links to start using the API explorer. A list of every table the user can write to with each of their /db/table/-/insert endpoints for example.
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299597066 https://github.com/simonw/datasette/issues/1871#issuecomment-1299597066 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NdkcK simonw 9599 2022-11-02T05:32:22Z 2022-11-02T05:32:22Z OWNER

Demo of the latest API explorer:

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299388341 https://github.com/simonw/datasette/issues/1871#issuecomment-1299388341 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5Ncxe1 simonw 9599 2022-11-02T00:24:28Z 2022-11-02T00:25:00Z OWNER

I want JSON syntax highlighting.

https://github.com/luyilin/json-format-highlight is an MIT licensed tiny highlighter that looks decent for this.

https://unpkg.com/json-format-highlight@1.0.1/dist/json-format-highlight.js

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1299349741 https://github.com/simonw/datasette/issues/1871#issuecomment-1299349741 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NcoDt simonw 9599 2022-11-01T23:22:55Z 2022-11-01T23:22:55Z OWNER

It's weird that the API explorer only lets you explore POST APIs. It should probably also let you explore GET APIs, or be renamed.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296339386 https://github.com/simonw/datasette/issues/1871#issuecomment-1296339386 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NRJG6 simonw 9599 2022-10-30T20:03:04Z 2022-10-30T20:03:04Z OWNER

I do need to skip CSRF for these API calls. I'm going to start out by doing that using the skip_csrf() hook to skip CSRF checks on anything with a content-type: application/json request header.

python @hookimpl def skip_csrf(scope): if scope["type"] == "http": headers = scope.get("headers") if dict(headers).get(b'content-type') == b'application/json': return True

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296339205 https://github.com/simonw/datasette/issues/1871#issuecomment-1296339205 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NRJEF simonw 9599 2022-10-30T20:02:05Z 2022-10-30T20:02:05Z OWNER

Realized the API explorer doesn't need the API key piece at all - it can work with standard cookie-based auth.

This also reflects how most plugins are likely to use this API, where they'll be adding JavaScript that uses fetch() to call the write API directly.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296131872 https://github.com/simonw/datasette/issues/1871#issuecomment-1296131872 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQWcg simonw 9599 2022-10-30T06:27:56Z 2022-10-30T06:27:56Z OWNER

Initial prototype API explorer is now live at https://latest-1-0-dev.datasette.io/-/api

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296130073 https://github.com/simonw/datasette/issues/1871#issuecomment-1296130073 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQWAZ simonw 9599 2022-10-30T06:20:56Z 2022-10-30T06:20:56Z OWNER

That initial prototype looks like this:

It currently shows the returned JSON from the API in an alert(). Next I should make that part of the page instead.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296126389 https://github.com/simonw/datasette/issues/1871#issuecomment-1296126389 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQVG1 simonw 9599 2022-10-30T06:04:48Z 2022-10-30T06:04:48Z OWNER

This is even more important now I have pushed: - #1866

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  
1296114136 https://github.com/simonw/datasette/issues/1871#issuecomment-1296114136 https://api.github.com/repos/simonw/datasette/issues/1871 IC_kwDOBm6k_c5NQSHY simonw 9599 2022-10-30T05:15:40Z 2022-10-30T05:15:40Z OWNER

Host it at /-/api

It's an input box with a path in and a textarea you can put JSON in, plus a submit button to post the request.

It lists the API endpoints you can use - click on a link to populate the form field plus a example.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
API explorer tool 1427293909  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 524.008ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows