Skip to content

Conversation

@valentin-dassonville
Copy link
Contributor

Q A
Branch 4.0
License MIT

@valentin-dassonville valentin-dassonville force-pushed the fix/hydra-context-static-asset branch 2 times, most recently from 97db06a to 0454297 Compare October 30, 2024 13:34
@vincentchalamon
Copy link
Contributor

@soyuka it seems to work on api-platform/demo#472

@dunglas
Copy link
Member

dunglas commented Nov 4, 2024

Can't we merge the Hydra context in the context we generate? So we avoid an extra HTTP request.

@valentin-dassonville valentin-dassonville force-pushed the fix/hydra-context-static-asset branch from 0a4dedf to 92009ff Compare November 5, 2024 13:42
@valentin-dassonville valentin-dassonville force-pushed the fix/hydra-context-static-asset branch from 92009ff to 36e4d08 Compare November 5, 2024 13:51
@valentin-dassonville valentin-dassonville changed the title fix(hydra): store and use hydra context as static asset fix(hydra): store and use hydra context in a local variable Nov 5, 2024
And the JSON node "@context[0]" should be equal to:
"""
{
"@context": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest doing something dynamic like:

  1. Download the original context from Hydra's website
  2. Assert that the context we generate is in sync with the upstream one

This will have the benefit of not bloating the tests and making the CI red if upstream changes the context.

WDYT?

public function getResourceContextUri(string $resourceClass, int $referenceType = UrlGeneratorInterface::ABS_PATH): string;

public const HYDRA_CONTEXT = [
'@context' => [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could we store this in an external PHP file that we automatically generate from the upstream JSON (so we can regenerate the file if needed).

@soyuka soyuka force-pushed the fix/hydra-context-static-asset branch from ade6748 to d24d2ce Compare November 6, 2024 09:33
@soyuka soyuka force-pushed the fix/hydra-context-static-asset branch from d24d2ce to a7e14dc Compare November 6, 2024 09:38
@soyuka soyuka merged commit 9ac3661 into api-platform:4.0 Nov 6, 2024
59 checks passed
@soyuka
Copy link
Member

soyuka commented Nov 6, 2024

Thanks @valentin-dassonville !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants