api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
480 stars 130 forks source link

Duplicated requests to API without pagination parameters #508

Open byfareska opened 11 months ago

byfareska commented 11 months ago

API Platform version(s) affected: 3.1.15, react admin 3.4.4

Description
Duplicated requests to API without pagination parameters on page load, menu usage or pagination.

How to reproduce
I've just pasted the index.js file from docs

import React from 'react';
import ReactDOM from 'react-dom';
import {
    AdminGuesser,
    hydraDataProvider,
    hydraSchemaAnalyzer,
} from '@api-platform/admin';

// Use your custom data provider or resource schema analyzer
// Hydra:
const dataProvider = hydraDataProvider({ entrypoint: 'http://localhost:63305' });
const schemaAnalyzer = hydraSchemaAnalyzer();
// OpenAPI:

const Admin = () => (
    <AdminGuesser
        dataProvider={dataProvider}
        schemaAnalyzer={schemaAnalyzer}
    />
);

ReactDOM.render(<Admin />, document.getElementById('root'));

Edit: the problem is also visible on official app skeleton https://github.com/api-platform/api-platform/tree/v3.1.14 Additional Context
You can see these requests on this video: https://streamable.com/1pfy9s

fzaninotto commented 1 month ago

Reproduced. These requests seem to be necessary for introspection.

fzaninotto commented 1 month ago

The problem comes from @api-platform/api-doc-parser. To introspect the parameters of a resource, the Hydra parser has to fetch the getList route:

https://github.com/api-platform/api-doc-parser/blob/e8b49f2b452c4a19fab5eea86ec742c8201d381f/src/hydra/getParameters.ts#L1-L26

It should be possible to use the main schema instead

fzaninotto commented 1 month ago

Probably linked to https://github.com/api-platform/api-doc-parser/issues/115