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

Inlining an entity shape errors on missing id field (even though it's there) #168

Open
lakardion opened this issue Oct 7, 2023 · 1 comment

Comments

@lakardion
Copy link
Member

This is quite weird and it has to do with the CheckEntityIntegrity type utils that seems not to be able to properly infer the entity shape properly if we inline that model directly in the createApi.models.entity field.

Something like this fails the typecheck:

createApi({
  baseUri: '/some-uri/',
  client,
  models: {
    entity: {
      id: z.string().uuid(),
      name: z.string(),
    },
  },
})

But this one doesn't:

const entityShape = {
  id: z.string().uuid(),
  name: z.string(),
}

createApi({
  baseUri: '/dietary-intake/',
  client,
  models: {
    entity: entityShape,
  },
})
@lakardion lakardion changed the title Inlining an entity shape errors on missing id field Inlining an entity shape errors on missing id field (even though it's there) Oct 7, 2023
@lakardion
Copy link
Member Author

Might end up removing this check altogether, however I feel it is a good typecheck to make sure that people include id in entity since it is used in built-ins

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

No branches or pull requests

1 participant