diff --git a/swh/graphql/resolvers/directory_entry.py b/swh/graphql/resolvers/directory_entry.py --- a/swh/graphql/resolvers/directory_entry.py +++ b/swh/graphql/resolvers/directory_entry.py @@ -20,6 +20,10 @@ def target_hash(self): # for DirectoryNode return self._node.target + @property + def targetType(self): # To support the schema naming convention + return self._node.type + class DirectoryEntryConnection(BaseConnection): """ diff --git a/swh/graphql/resolvers/search.py b/swh/graphql/resolvers/search.py --- a/swh/graphql/resolvers/search.py +++ b/swh/graphql/resolvers/search.py @@ -13,6 +13,10 @@ class SearchResultNode(BaseNode): """ """ + @property + def targetType(self): # To support the schema naming convention + return self._node.type + class ResolveSwhidConnection(BaseConnection): diff --git a/swh/graphql/resolvers/snapshot_branch.py b/swh/graphql/resolvers/snapshot_branch.py --- a/swh/graphql/resolvers/snapshot_branch.py +++ b/swh/graphql/resolvers/snapshot_branch.py @@ -34,6 +34,10 @@ def is_type_of(self): return "Branch" + @property + def targetType(self): # To support the schema naming convention + return self._node.type + def snapshot_swhid(self): """ Logic to handle multiple branch alias redirects diff --git a/swh/graphql/schema/schema.graphql b/swh/graphql/schema/schema.graphql --- a/swh/graphql/schema/schema.graphql +++ b/swh/graphql/schema/schema.graphql @@ -474,7 +474,7 @@ """ Type of Branch target """ - type: BranchTargetType + targetType: BranchTargetType """ Branch target object @@ -703,7 +703,7 @@ """ Possible directory entry types """ -enum DirectoryEntryType { +enum DirectoryEntryTargetType { dir file rev @@ -721,7 +721,7 @@ """ Directory entry object type; can be file, dir or rev """ - type: DirectoryEntryType + targetType: DirectoryEntryTargetType """ Directory entry target object @@ -913,7 +913,7 @@ """ Result target type """ - type: SearchResultTargetType + targetType: SearchResultTargetType """ Result target object diff --git a/swh/graphql/tests/functional/test_branch_connection.py b/swh/graphql/tests/functional/test_branch_connection.py --- a/swh/graphql/tests/functional/test_branch_connection.py +++ b/swh/graphql/tests/functional/test_branch_connection.py @@ -22,7 +22,7 @@ cursor } nodes { - type + targetType name { text } @@ -72,7 +72,7 @@ "__typename": "Revision", "swhid": "swh:1:rev:66c7c1cd9673275037140f2abff7b7b11fc9439c", }, - "type": "revision", + "targetType": "revision", } @@ -83,7 +83,7 @@ assert node == { "name": {"text": "target/alias"}, "target": {"__typename": "Branch", "name": {"text": "target/revision"}}, - "type": "alias", + "targetType": "alias", } diff --git a/swh/graphql/tests/functional/test_content.py b/swh/graphql/tests/functional/test_content.py --- a/swh/graphql/tests/functional/test_content.py +++ b/swh/graphql/tests/functional/test_content.py @@ -143,7 +143,7 @@ swhid entries(first: 2) { nodes { - type + targetType target { ...on Content { swhid diff --git a/swh/graphql/tests/functional/test_directory_entry.py b/swh/graphql/tests/functional/test_directory_entry.py --- a/swh/graphql/tests/functional/test_directory_entry.py +++ b/swh/graphql/tests/functional/test_directory_entry.py @@ -17,7 +17,7 @@ swhid entries { nodes { - type + targetType name { text } @@ -30,7 +30,7 @@ directory_entries = data["directory"]["entries"]["nodes"] assert len(directory_entries) == len(directory.entries) output = [ - {"name": {"text": de.name.decode()}, "type": de.type} + {"name": {"text": de.name.decode()}, "targetType": de.type} for de in directory.entries ] for each_entry in output: diff --git a/swh/graphql/tests/functional/test_revision.py b/swh/graphql/tests/functional/test_revision.py --- a/swh/graphql/tests/functional/test_revision.py +++ b/swh/graphql/tests/functional/test_revision.py @@ -94,7 +94,7 @@ snapshot(swhid: "%s") { branches(first: 1, types: [revision]) { nodes { - type + targetType target { ...on Revision { swhid diff --git a/swh/graphql/tests/functional/test_search.py b/swh/graphql/tests/functional/test_search.py --- a/swh/graphql/tests/functional/test_search.py +++ b/swh/graphql/tests/functional/test_search.py @@ -11,7 +11,7 @@ { search(query: "fox", first: 1) { nodes { - type + targetType target { ...on Origin { url @@ -38,7 +38,7 @@ "url": "https://somewhere.org/den/fox", "latestVisit": {"date": "2018-11-27T17:20:39+00:00"}, }, - "type": "origin", + "targetType": "origin", } ], "pageInfo": {"endCursor": "MQ==", "hasNextPage": True}, @@ -51,7 +51,7 @@ { search(query: "missing-fox", first: 1) { nodes { - type + targetType } pageInfo { hasNextPage diff --git a/swh/graphql/tests/functional/test_snapshot_node.py b/swh/graphql/tests/functional/test_snapshot_node.py --- a/swh/graphql/tests/functional/test_snapshot_node.py +++ b/swh/graphql/tests/functional/test_snapshot_node.py @@ -18,7 +18,7 @@ swhid branches(first:5) { nodes { - type + targetType name { text } diff --git a/swh/graphql/tests/functional/test_swhid_resolve.py b/swh/graphql/tests/functional/test_swhid_resolve.py --- a/swh/graphql/tests/functional/test_swhid_resolve.py +++ b/swh/graphql/tests/functional/test_swhid_resolve.py @@ -20,7 +20,7 @@ { resolveSwhid(swhid: "swh:1:dir:dae0d245988b472abd30a4f968b919d0019b6c7") { nodes { - type + targetType } } } @@ -46,7 +46,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType } } } @@ -62,7 +62,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType target { __typename ... on Snapshot { @@ -82,7 +82,7 @@ "__typename": "Snapshot", "swhid": str(snapshot.swhid()), }, - "type": "snapshot", + "targetType": "snapshot", } ] } @@ -95,7 +95,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType target { __typename ... on Revision { @@ -115,7 +115,7 @@ "__typename": "Revision", "swhid": str(revision.swhid()), }, - "type": "revision", + "targetType": "revision", } ] } @@ -128,7 +128,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType target { __typename ... on Release { @@ -148,7 +148,7 @@ "__typename": "Release", "swhid": str(release.swhid()), }, - "type": "release", + "targetType": "release", } ] } @@ -161,7 +161,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType target { __typename ... on Directory { @@ -181,7 +181,7 @@ "__typename": "Directory", "swhid": str(directory.swhid()), }, - "type": "directory", + "targetType": "directory", } ] } @@ -194,7 +194,7 @@ { resolveSwhid(swhid: "%s") { nodes { - type + targetType target { __typename ... on Content { @@ -214,7 +214,7 @@ "__typename": "Content", "swhid": str(content.swhid()), }, - "type": "content", + "targetType": "content", } ] }