refine icon indicating copy to clipboard operation
refine copied to clipboard

[DOC] Query in code tutorial not reflects api url example

Open iaurg opened this issue 1 year ago • 5 comments

Documentation issue

I'm following the tutorial documentation, and I noticed that some code does not align with the provided examples. This discrepancy may confuse users going through the tutorial.

For instance, in the getList example found here: https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider/#getlist, the API params example is given as follows:

[GET] https://api.fake-rest.refine.dev/posts?_limit=10&_page=2

However, in the code below this example, a variable is created as follows:

...
const { current = 1, pageSize = 10 } = pagination ?? {};

const query: {
    _start?: number;
    _end?: number;
} = {
    _start: (current - 1) * pageSize,
    _end: current * pageSize,
};
...

I've tested both sets of parameters in the API URL, and they both work but return different results.

Could we use the same parameters in each example, or is there any issue with this approach?

Describe the thing to improve

Params examples and code

Describe the solution (optional)

No response

iaurg avatar Jan 13 '24 14:01 iaurg

Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have _start and _end parameters.

BatuhanW avatar Jan 15 '24 08:01 BatuhanW

Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have _start and _end parameters.

For consistency, you should align the code with the example URL. In this case, you can modify the code to use _limit and _page instead of _start and _end:

const { current = 1, pageSize = 10 } = pagination ?? {};

const query: {
    _limit?: number;
    _page?: number;
} = {
    _limit: pageSize,
    _page: current,
};

Conqxeror avatar Jan 15 '24 10:01 Conqxeror

Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have _start and _end parameters.

For consistency, you should align the code with the example URL. In this case, you can modify the code to use _limit and _page instead of _start and _end:

const { current = 1, pageSize = 10 } = pagination ?? {};

const query: {
    _limit?: number;
    _page?: number;
} = {
    _limit: pageSize,
    _page: current,
};

This doc is referencing to simple-rest data provider, and we are using _start, _end parameters in this package, see here.

So it's better to be consistent with the code in the data provider.

BatuhanW avatar Jan 15 '24 10:01 BatuhanW

Hello @iaurg thanks for the report! Would you like to create a PR for this issue? As you mentioned, example request should have _start and _end parameters.

For consistency, you should align the code with the example URL. In this case, you can modify the code to use _limit and _page instead of _start and _end:

const { current = 1, pageSize = 10 } = pagination ?? {};

const query: {
    _limit?: number;
    _page?: number;
} = {
    _limit: pageSize,
    _page: current,
};

This doc is referencing to simple-rest data provider, and we are using _start, _end parameters in this package, see here.

So it's better to be consistent with the code in the data provider.

Ohhkk👍 I just did the change and I was just going to push the commit. So there's no need to make any changes in it? If not, then we should close the issue.

Conqxeror avatar Jan 15 '24 10:01 Conqxeror

Screenshot 2024-01-15 at 14 49 18

We should update generated query parts in the documentation: https://github.com/refinedev/refine/blob/master/documentation/docs/tutorial/2-understanding-dataprovider/2-create-dataprovider.md#194

BatuhanW avatar Jan 15 '24 11:01 BatuhanW