Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function toResource needs to see the target content-type #34

Closed
bruderj15 opened this issue Dec 30, 2024 · 0 comments · Fixed by #32
Closed

Function toResource needs to see the target content-type #34

bruderj15 opened this issue Dec 30, 2024 · 0 comments · Fixed by #32
Labels
improvement Improve existing feature

Comments

@bruderj15
Copy link
Owner

Currently we have

class ToResource res a where
  toResource :: Proxy res -> a -> res a

instance Resource res => ToResource res User where
  toResource _ usr = addRel ("address", mkAddrLink $ addressId usr) $ wrap usr
    where
      mkAddrLink = toRelationLink (Proxy @AddressGetOne)

However in mkAddrLink we want to point to the address-resource, not the old endpoint from the plain api.
Therefore we need access to the content type so we can ref to the hateoas-endpoint.

class ToResource ct a where
  toResource :: Proxy ct -> Proxy a -> MkResource ct a

instance Resource (MkResource ct) => ToResource ct User where
  toResource _ usr = addRel ("address", mkAddrLink $ addressId usr) $ wrap usr
    where
      mkAddrLink = toRelationLink (Proxy @(Resourcify AddressGetOne ct))
@bruderj15 bruderj15 added the improvement Improve existing feature label Dec 30, 2024
@bruderj15 bruderj15 self-assigned this Dec 30, 2024
bruderj15 added a commit that referenced this issue Dec 30, 2024
@bruderj15 bruderj15 linked a pull request Dec 30, 2024 that will close this issue
@bruderj15 bruderj15 removed their assignment Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improve existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant