Page MenuHomePhabricator

Implement an "Attachments" behavior for Conduit Search APIs
ClosedPublic

Authored by epriestley on Dec 14 2015, 1:34 PM.
Tags
None
Referenced Files
F14040863: D14772.id.diff
Mon, Nov 11, 1:49 PM
F14036284: D14772.id.diff
Sun, Nov 10, 9:33 AM
F13990185: D14772.id35733.diff
Tue, Oct 22, 1:50 AM
F13974129: D14772.id35727.diff
Fri, Oct 18, 4:13 AM
F13972009: D14772.id35733.diff
Thu, Oct 17, 4:39 PM
F13965584: D14772.id35725.diff
Wed, Oct 16, 2:57 AM
Unknown Object (File)
Oct 9 2024, 8:31 AM
Unknown Object (File)
Oct 9 2024, 2:55 AM
Subscribers
None

Details

Summary

Ref T9964. We have various kinds of secondary data on objects (like subscribers, projects, paste content, Owners paths, file attachments, etc) which is somewhat slow, or somewhat large, or both.

Some approaches to handling this in the API include:

  • Always return all of it (very easy, but slow).
  • Require users to make separate API calls to get each piece of data (very simple, but inefficient and really cumbersome to use).
  • Implement a hierarchical query language like GraphQL (powerful, but very complex).
  • Kind of mix-and-match a half-power query language and some extra calls? (fairly simple, not too terrible?)

We currently mix-and-match internally, with ->needStuff(true). This is not a general-purpose, full-power graph query language like GraphQL, and it occasionally does limit us.

For example, there is no way to do this sort of thing:

$conpherence_thread_query = id(new ConpherenceThreadQuery())
  ->setViewer($viewer)
  // ...
  ->setNeedMessages(true)
  ->setWhenYouLoadTheMessagesTheyNeedProfilePictures(true);

However, we almost never actually need to do this and when we do want to do it we usually don't really want to do it, so I don't think this is a major limit to the practical power of the system for the kinds of things we really want to do with it.

Put another way, we have a lot of 1-level hierarchical queries (get pictures or repositories or projects or files or content for these objects) but few-to-no 2+ level queries (get files for these objects, then get all the projects for those files).

So even though 1-level hierarchies are not a beautiful, general-purpose, fully-abstract system, they've worked well so far in practice and I'm comfortable moving forward with them in the API.

If we do need N-level queries in the future, there is no technical reason we can't put GraphQL (or something similar) on top of this eventually, and this would represent a solid step toward that. However, I suspect we'll never need them.

Upshot: I'm pretty happy with "->needX()" for all practical purposes, so this is just adding a way to say "->needX()" to the API.

Specifically, you say:

{
  "attachments": {
    "subscribers": true,
  }
}

...and get back subscriber data. In the future (or for certain attachments), true might become a dictionary of extra parameters, if necessary, and could do so without breaking the API.

Test Plan
  • Ran queries to get attachments.

Screen Shot 2015-12-14 at 5.16.27 AM.png (822×935 px, 104 KB)

Diff Detail

Repository
rP Phabricator
Branch
attach1
Lint
Lint Passed
SeverityLocationCodeMessage
Advicesrc/applications/search/engine/PhabricatorApplicationSearchEngine.php:1131XHP16TODO Comment
Unit
Tests Passed
Build Status
Buildable 9545
Build 11401: Run Core Tests
Build 11400: arc lint + arc unit

Event Timeline

epriestley retitled this revision from to Implement an "Attachments" behavior for Conduit Search APIs.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
  • Fix fumbling of return value.
  • Fix logic error which could over-report viewer as subscribed.
chad edited edge metadata.
This revision is now accepted and ready to land.Dec 14 2015, 3:33 PM