-
| Is there a way to get direct access to a  I'm going after this schema structure (from the GitHub GraphQL API) type LabelConnection {
  edges: [LabelEdge]
  nodes: [Label] # <-- nodes shorthand
  pageInfo: PageInfo!
  totalCount: Int!
}I tried subclassing both  | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
| Found a very hacky workaround for anyone interested, this patch works for 
 You'll need to patch the packages after install. --- site-packages/graphql_relay/connection/connectiontypes.py	2022-05-21 14:17:29.000000000 +0200
+++ site-packages/graphql_relay/connection/connectiontypes.py	2022-05-21 14:17:17.000000000 +0200
@@ -1,13 +1,17 @@
 class Connection(object):
-    def __init__(self, edges, page_info):
+    def __init__(self, edges, page_info, nodes, total_count):
         self.edges = edges
         self.page_info = page_info
+        self.nodes = nodes
+        self.total_count = total_count
     def to_dict(self):
         return {
             'edges': [e.to_dict() for e in self.edges],
             'pageInfo': self.page_info.to_dict(),
+            'nodes': self.nodes,
+            'totalCount': len(self.nodes)
         }--- site-packages/graphql_relay/connection/arrayconnection.py	2022-05-21 14:06:15.000000000 +0200
+++ site-packages/graphql_relay/connection/arrayconnection.py	2022-05-21 14:04:43.000000000 +0200
@@ -95,6 +95,8 @@
     return connection_type(
         edges=edges,
+        nodes=_slice,
+        total_count=list_length,
         page_info=pageinfo_type(
             start_cursor=first_edge_cursor,
             end_cursor=last_edge_cursor,--- site-packages/graphene/relay/connection.py	2022-05-21 14:06:29.000000000 +0200
+++ site-packages/graphene/relay/connection.py	2022-05-21 14:11:51.000000000 +0200
@@ -91,6 +91,7 @@
         cls.Edge = edge
         options["name"] = name
+        options["description"] = "The connection type for {}.".format(base_name)
         _meta.node = node
         _meta.fields = OrderedDict(
             [
@@ -106,10 +107,26 @@
                 (
                     "edges",
                     Field(
-                        NonNull(List(edge)),
+                        # NonNull(List(edge)),
+                        NonNull(List(NonNull(edge))),
                         description="Contains the nodes in this connection.",
                     ),
                 ),
+                (
+                    "nodes",
+                    Field(
+                        # NonNull(List(_node)),
+                        NonNull(List(NonNull(_node))),
+                        description="A list of nodes.",
+                    ),
+                ),
+                (
+                    "total_count",
+                    Field(
+                        NonNull(Int),
+                        description="Identifies the total count of items in the connection.",
+                    ),
+                ),
             ]
         )
         return super(Connection, cls).__init_subclass_with_meta__( | 
Beta Was this translation helpful? Give feedback.
-
| Ma diventerà mai una feature ufficiale? Non riusciamo ad ottenerla estendendo qualcosa? | 
Beta Was this translation helpful? Give feedback.
Found a very hacky workaround for anyone interested, this patch works for
graphene==2.1.9graphql-relay==2.0.1graphene-django==2.15.0You'll need to patch the packages after install.