Skip to content
Snippets Groups Projects
Commit 7bfc6143c1b7 authored by Frank Bessou's avatar Frank Bessou :spider_web:
Browse files

feat: make createDataProvider take an rqlClient as input

The rqlClient is used so often that we can expect it to be available
when creating the data provider.
parent 7e81ecb8d2f4
No related branches found
No related tags found
1 merge request!3feat: make createDataProvider take an rqlClient as input
......@@ -18,6 +18,7 @@
SimpleShowLayout,
DataProvider,
} from "react-admin";
import { client } from "@logilab/cwclientlibjs";
import { createDataProvider } from "ra-cubicweb/dist";
import { schema } from "./schema";
......@@ -81,7 +82,10 @@
</Show>
);
const dataProvider = createDataProvider("http://localhost:8080", schema);
const httpClient = new client.CwSimpleHttpClient("http://localhost:8080", true);
const rqlClient = new client.CwRqlClient(httpClient);
const dataProvider = createDataProvider(rqlClient, schema);
dataProvider.getList("toto", {
pagination: { page: 1, perPage: 10 },
sort: { field: "id", order: "ASC" },
......
......@@ -16,6 +16,6 @@
};
export function createDataProvider<S extends Schema>(
endpoint: string,
rqlClient: client.CwRqlClient,
schema: S
): DataProvider {
......@@ -20,7 +20,5 @@
schema: S
): DataProvider {
const httpClient = new client.CwSimpleHttpClient(endpoint, true);
const rqlClient = new client.CwRqlClient(httpClient);
return {
getList: async (resource: ETypesNames<S>, { pagination, sort }) => {
const sortAttribute = sort.field === "id" ? "eid" : sort.field;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment