Page MenuHomeSoftware Heritage

Possibility to search with a SWHID.
AbandonedPublic

Authored by jayeshv on May 24 2022, 11:33 AM.

Details

Reviewers
vlorentz
Group Reviewers
Reviewers
Summary

First feature in the search entrypoint.
Search with a SWHID and get the corresponding object.
error conditions: "Invalid SWHID error"
or "Requested object is not available" error

Related to: T4263

Diff Detail

Repository
rDGQL GraphQL API
Branch
search-entrypoint
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 29553
Build 46179: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 46178: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D7887 (id=28462)

Rebasing onto d5010fd75f...

Current branch diff-target is up to date.
Changes applied before test
commit 61ffc5f0dc206dae56ad5c5efc6bd8eec83b2104
Author: Jayesh Velayudhan <jayesh@softwareheritage.org>
Date:   Fri May 20 16:07:30 2022 +0200

    Possibility to search with a SWHID.
    
    First feature in the search entrypoint.
    Search with a SWHID and get the corresponding object.
    error conditions:  "Invalid SWHID error"
    or "Requested object is not available" error
    
    Related to: T4263

See https://jenkins.softwareheritage.org/job/DGQL/job/tests-on-diff/28/ for more details.

Build is green

Patch application report for D7887 (id=28463)

Rebasing onto d5010fd75f...

Current branch diff-target is up to date.
Changes applied before test
commit 3ec4cd57c66b416c61fea2d3b74565c81a093ddd
Author: Jayesh Velayudhan <jayesh@softwareheritage.org>
Date:   Fri May 20 16:07:30 2022 +0200

    Possibility to search with a SWHID.
    
    First feature in the search entrypoint.
    Search with a SWHID and get the corresponding object.
    error conditions:  "Invalid SWHID error"
    or "Requested object is not available" error
    
    Related to: T4263

See https://jenkins.softwareheritage.org/job/DGQL/job/tests-on-diff/29/ for more details.

vlorentz added a subscriber: vlorentz.

Please omit the redundant help strings in the schema (eg. Connection to search results on type SearchResultConnection); and reword the commit/diff title to follow https://docs.softwareheritage.org/devel/contributing/git-style-guide.html

The When the XXX is requested directly with its SWHID docstrings sometimes on classes, and sometimes on methods; this looks like typos.
And what about writing the docstrings on a base class instead of repeating them five times?

Also, I have no idea what this means. Docstrings should describe the object, not (what I assume is) when they are used.

swh/graphql/errors/errors.py
12 ↗(On Diff #28462)

please document this

swh/graphql/resolvers/resolver_factory.py
45–66

Why .lower()?

swh/graphql/resolvers/search.py
1

please add a copyright header

swh/graphql/schema/schema.graphql
966–968

shouldn't it be in the docstring of the function rather than the argument?

970

For future-proofing, I think you should return a list. Once we move to SWHIDv2, we may have multiple objects with the same SWHIDv1.

This revision now requires changes to proceed.May 24 2022, 11:53 AM
swh/graphql/resolvers/resolver_factory.py
45–66

@vlorentz C oreSwhid.object_type.name is a string in capitals. Resolver factory is using small letters to find a type. I will remove lower here and do this at the source itself.

swh/graphql/schema/schema.graphql
970

@vlorentz Good. I prefer a connection (a paginated list) here, did this to match the 'resolve' api endpoint.

Should we also support resolving manySWHIDs in one request (list of SWHIDs as input) ?

swh/graphql/schema/schema.graphql
970

Ah, good point. I didn't consider that there may be many objects with the same SWHID