# HG changeset patch
# User Noe Gaumont <ngaumont@logilab.fr>
# Date 1613141869 -3600
#      Fri Feb 12 15:57:49 2021 +0100
# Node ID 8a977db3ceb1b6239a28240d6a2b99b248e16c3e
# Parent  ac514970ebfc66aef1b5ba701b38f254daeadae5
feat(getOne): retrieve attributes with rqlio

diff --git a/packages/demo/src/App.tsx b/packages/demo/src/App.tsx
--- a/packages/demo/src/App.tsx
+++ b/packages/demo/src/App.tsx
@@ -35,7 +35,7 @@
 
 const MuseumList = (props: ListProps) => (
   <List {...props}>
-    <Datagrid rowClick="edit">
+    <Datagrid rowClick="show">
       <NumberField source="id" />
       <TextField source="name" />
       <NumberField source="latitude" />
diff --git a/packages/ra-cubicweb/src/index.ts b/packages/ra-cubicweb/src/index.ts
--- a/packages/ra-cubicweb/src/index.ts
+++ b/packages/ra-cubicweb/src/index.ts
@@ -60,19 +60,28 @@
           };
         });
     },
-    getOne: (resource: keyof S["etypes"], _params) => {
-      return fetch(
-        `${endpoint}/view?rql=Any+C+LIMIT+1+WHERE+C+is+${resource}+,+C+eid+${_params.id}&vid=ejsonexport`
-      )
-        .then((resp) => resp.json())
-        .then((json) => {
-          return {
-            data: json.map((entity: Entity) => ({
-              ...entity,
-              id: entity.eid,
-            }))[0],
-          };
-        });
+    getOne: async (resource: ETypesNames<S>, _params) => {
+      const attributesNames = ["eid", ...Object.keys(schema.etypes[resource])];
+      const selection: string[] = [];
+      const restrictions: string[] = [];
+      attributesNames.forEach((key, idx) => {
+        const variable = `X${idx}`;
+        selection.push(variable);
+        restrictions.push(`X ${key} ${variable}`);
+      });
+      const result = await rqlClient.queryRows(
+        `Any ${selection.join(",")} Where ${restrictions.join(",")}`
+      );
+      const row = result[0];
+      return {
+        data: row.reduce(
+          (agg, attributeValue, idx) => ({
+            [attributesNames[idx]]: attributeValue,
+            ...agg,
+          }),
+          { id: row[0] }
+        ),
+      };
     },
     getMany: (_resource, _params) => Promise.reject("Not implemented"),
     getManyReference: (_resource, _params) => Promise.reject("Not implemented"),