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

Prevent type error if user accidentally sends readonly field in output shape #161

Open
lakardion opened this issue Sep 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@lakardion
Copy link
Member

const userShape = {
  ...baseModelShape,
  email: z.string().email(),
  firstName: z.string(),
  lastName: z.string(),
  token: readonly(z.string().nullable()),
}

const login = createCustomServiceCall(
  {
    inputShape: loginShape,
    outputShape: userShape,
  },
  async ({ client, input, utils }) => {
    const res = await client.post('/login/', utils.toApi(input))
    return utils.fromApi(res.data)
  },
)

The readonly in token for the user shape would cause an error on the custom call layer declaring it to be of an invalid type.

@lakardion lakardion added the bug Something isn't working label Sep 21, 2023
@lakardion
Copy link
Member Author

Solution would be to just ignore zod branded in output shapes. Right now we're not allowing zod branded as part of an output shape type 🤔 would need to check further though but this is my initial guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant