-
-
Notifications
You must be signed in to change notification settings - Fork 133
Open
Description
API Platform version(s) affected: api: 3.3, admin: 3.4.6
Description
When accessing a resource from the admin, several extra calls seem to be made on top of the main call fetching the data:

These calls seem to be initiated by the Guesser Components to fetch the schema:

These calls do include a JWT but this token is not refreshed if expired. The JWT in the "main" call is correctly updated.
How to reproduce
- Clone Api Platform Demo repository
- Remove components so that the Guesser components do their job
Possible Solution
n/a
Additional Context
- Code is very close to the Demo:
// Admin.jsx
const apiDocumentationParser = (session) => async () => {
try {
return await parseHydraDocumentationWithEnums(ENTRYPOINT, {
headers: {
Authorization: `Bearer ${session?.accessToken}`,
},
});
} catch (result) {
// @ts-ignore
const { api, response, status } = result;
if (status !== 401 || !response) {
throw result;
}
return {
api,
response,
status,
};
}
};
const AdminUI = ({ children, session }) => {
const dataProvider = useRef();
const { docType } = useContext(DocContext);
dataProvider.current = hydraDataProvider({
entrypoint: ENTRYPOINT,
httpClient: (url, options = {}) => fetchHydra(url, {
...options,
headers: {
Authorization: `Bearer ${session?.accessToken}`,
},
}),
apiDocumentationParser: apiDocumentationParser(session),
});
return docType === "hydra" ? (
<HydraAdmin
requireAuth
authProvider={authProvider}
// @ts-ignore
dataProvider={dataProvider.current}
entrypoint={window.origin}
i18nProvider={i18nProvider}
layout={MyLayout}
>
{!!children && children}
</HydraAdmin>
) : (
<OpenApiAdmin
requireAuth
authProvider={authProvider}
// @ts-ignore
dataProvider={dataProvider.current}
entrypoint={window.origin}
docEntrypoint={`${window.origin}/docs.json`}
i18nProvider={i18nProvider}
layout={MyLayout}
>
{!!children && children}
</OpenApiAdmin>
);
};
const AdminWithContext = ({ session }) => {
const [docType, setDocType] = useState(
store.getItem("docType", "hydra"),
);
return (
<DocContext.Provider
value={{
docType,
setDocType,
}}>
<AdminUI session={session}>
// No Resources defined here unlike in the demo repo
</AdminUI>
</DocContext.Provider>
);
};- parseHydraDocumentationWithEnums is based on Admin interface not rendering dropdown for Enum on HydraAdmin #494 (comment) doesn't seem to be the source as when using the normal
parseHydraDocumentationproblem remains. - Calls are made every time we access the resource from the admin if no ApiFilter is defined in the API
- If ApiFilter is defined in the API then calls are only made the first time we try to access the resource. If the resource is not accessed at least once before the initial token expires the problem remains
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels