In D8426#219120, @vlorentz wrote:Here is a way to do it:
diff --git a/swh/graphql/resolvers/resolvers.py b/swh/graphql/resolvers/resolvers.py index 60992bb..1b0e93f 100644 --- a/swh/graphql/resolvers/resolvers.py +++ b/swh/graphql/resolvers/resolvers.py @@ -93,6 +93,8 @@ def snapshot_resolver( def visit_snapshot_resolver( obj, info: GraphQLResolveInfo, **kw ) -> rs.snapshot.VisitSnapshotNode: + if obj.snapshotSWHID is None: + return None resolver = get_node_resolver("visit-snapshot") return resolver(obj, info, **kw) diff --git a/swh/graphql/tests/functional/test_visit_status.py b/swh/graphql/tests/functional/test_visit_status.py index a250a9a..d83861a 100644 --- a/swh/graphql/tests/functional/test_visit_status.py +++ b/swh/graphql/tests/functional/test_visit_status.py @@ -28,7 +28,7 @@ def test_get_visit_status(client): visit.origin, visit.visit, ) - data, _ = get_query_response(client, query_str) + data, err = get_query_response(client, query_str) result_status = get_visit_status()[3] assert data["visit"]["status"]["nodes"][0] == { "date": result_status.date.isoformat(), @@ -36,6 +36,7 @@ def test_get_visit_status(client): "status": result_status.status, "type": result_status.type, } + assert err is None def test_get_visit_missing_snapshot(client): @@ -67,7 +68,4 @@ def test_get_visit_missing_snapshot(client): "status": result_status.status, "type": result_status.type, } - assert len(err) == 1 - assert ( - "Cannot return null for non-nullable field Snapshot.swhid" in err[0]["message"] - ) + assert err is None
- Queries
- All Stories
- Search
- Advanced Search
- Transactions
- Transaction Logs
Feed Advanced Search
Advanced Search
Advanced Search
Sep 9 2022
Sep 9 2022
update error to raise
In D8426#219093, @vlorentz wrote:Sure, but in that example, the error is because for some reason, they could not get the value of name for an object that exists. The error in the example even reflects this, as it mentions "character with ID 1002".
In our case, that object does not exist at all.
In D8426#219084, @vlorentz wrote:The section you linked mentions null values in Non-Null fields, but not of null values for objects with a Non-Null field.
Are you sure this is disallowed by the standard, not "only" a bug in the GraphQL library we use?
In D8426#219084, @vlorentz wrote:The section you linked mentions null values in Non-Null fields, but not of null values for objects with a Non-Null field.
Are you sure this is disallowed by the standard, not "only" a bug in the GraphQL library we use?
In D8426#219070, @vlorentz wrote:In D8426#219051, @jayeshv wrote:The issue is snapshot has non nullable fields (like SWHID) and GraphQL standard will not allow a
null for an object with non nullable field without an error.I can't find what part of the standard disallows it, nor any mention one way or another outside the standard. Any pointer?
In D8426#219077, @anlambert wrote:In D8426#219076, @jayeshv wrote:> I do not get the issue here, using the following changes on top of your diff, it works as expected: >It will work as expected in the data part. But there will be an error associated, that we think is unnecessary.
With your changes, it will be a "NoneType' object has no attribute 'object_id" instead of an ObjectErrorCould you write a snippet query to reproduce the error ? I still do not get what's wrong here.
> I do not get the issue here, using the following changes on top of your diff, it works as expected: >
It will work as expected in the data part. But there will be an error associated, that we think is unnecessary.
With your changes, it will be a "NoneType' object has no attribute 'object_id" instead of an ObjectError
In D8426#219043, @vlorentz wrote:Why have two different types, instead of making the snapshot field nullable, like this?
type VisitStatus { status: String! date: DateTime! type: String snapshot: Snapshot }
@vlorentz The right fix is to add a new visit status type to the schema like below.
jayeshv closed T4508: GraphQL: Add a directoryEntry entry point, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
jayeshv committed rDGQL6e5d34e94de1: Add revision object as a possible directory entry target (authored by jayeshv).
Add revision object as a possible directory entry target
Add a directoryEntry entrypoint
remove ununsed test
use parametrize in directory entry tests
remove wrong code
address review comments
Sep 8 2022
Sep 8 2022
In D8426#218850, @vlorentz wrote:Should this really be an error? Isn't it enough to set snapshot to null?
In D8426#218850, @vlorentz wrote:Should this really be an error? Isn't it enough to set snapshot to null?
jayeshv added a comment to T4514: graphql: object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>).
This is a bit tricky to fix.
Snapshot is available only in a visit status with 'full' status. But there is only one visit-status object and it has a field snapshot.
Did a fix that returns a sensible error instead of a creepy one.
jayeshv added a revision to T4508: GraphQL: Add a directoryEntry entry point: D8396: Add a directoryEntry entrypoint.
update the commit message
Sep 6 2022
Sep 6 2022
In D8396#218275, @vlorentz wrote:As this allows nested paths, then the cost calculator needs to take into account the number of / in the path, as each of them requires two joins in the database
Sep 5 2022
Sep 5 2022
jayeshv closed T4492: GraphQL: rename type fields to targetType for consistency, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
jayeshv committed rDGQL467e0b7e28bc: Rename 'type' field to 'targetType' in the schema (authored by jayeshv).
Rename 'type' field to 'targetType' in the schema
jayeshv triaged T4492: GraphQL: rename type fields to targetType for consistency as Normal priority.
Sep 2 2022
Sep 2 2022
add a custom validator
jayeshv committed rDGQL6b1c5797f711: Raise InvalidInputError on an invalid SWHID input (authored by jayeshv).
Raise InvalidInputError on an invalid SWHID input
Sep 1 2022
Sep 1 2022
Remove the option to use a WSGI server
Aug 31 2022
Aug 31 2022
Remove unused middlewares package
Add a centralized error handler
address review comments
post to sentry
jayeshv retitled D8356: Add a centralized error handler from [WIP] Add a centralized error handler to Add a centralized error handler.
doc improvements
jayeshv added a revision to T4300: GraphQL: Collect code metric and add logging: D8356: Add a centralized error handler.
Aug 30 2022
Aug 30 2022
doc string update
fix tests
jayeshv retitled D8077: Add a static query cost calculator to reject malicious quries from [WIP] Add a basic query cost validator to [WIP] Add a static query cost calculator to reject malicious quries.
Using multipliers
Aug 29 2022
Aug 29 2022
Aug 26 2022
Aug 26 2022
jayeshv closed T4366: GraphQL: add revision log to the revision type, a subtask of T4083: New public API (GraphQL + thin layer), as Resolved.
jayeshv committed rDGQL4478a533a9b1: Remove hard-coded object ids from functional tests (authored by jayeshv).
Remove hard-coded object ids from functional tests
rebase
Enable cors for the asgi server
jayeshv retitled D8319: Enable cors in the asgi server from Enable cors in the dev server to Enable cors in the asgi server.
Changed dev to asgi in the the doc and commit message
jayeshv committed rDGQLa31419d74c45: Add revision log field in the revision type (authored by jayeshv).
Add revision log field in the revision type
fix typo