computedTypesResolver does not work with nested fields
See original GitHub issueDescribe the bug
I have a schema like so:
const schema = Schema({
top: string.min(100),
nested: Schema({
value: string.min(100),
}),
})
Errors in the top-level fields are reported correctly, while errors in nested fields are lost.
To Reproduce
- Go to https://codesandbox.io/s/react-hook-form-computed-types-nested-fields-validation-error-bug-9uuuuq?file=/src/index.jsx
- Run
- See in the console how the error on the ‘top’ field is reported but not on the nested field.
Codesandbox link (Required)
Additional context
Not sure what the expected shape of FieldErrors
should be, if it should be a nested object or flat where keys are dot-separated field paths. If the later then fixing computedTypesResolver can be as easy as changing parseErrorSchema like so:
const parseErrorSchema = (computedTypesError: ValidationError): FieldErrors => {
const parsedErrors: FieldErrors = {};
for (const { path, error } of computedTypesError.errors || []) {
parsedErrors[path.join(".")] = {
type: error.name,
message: error.message,
};
}
return parsedErrors;
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Nested fields issue · Issue #154 · graphql/graphql-js - GitHub
Consider following code: Schema: const userType = new GraphQLObjectType({ name: 'User', description: 'User type', fields: () => ({ id: ...
Read more >Advanced topics on federated entities - Apollo GraphQL Docs
This article describes complex behaviors of federated entities beyond those covered in entity basics. Advanced @key s. A single entity can have multiple ......
Read more >Invoke resolvers of fields on nested execution levels in NestJS ...
I'm building a GraphQL API in NestJS supporting queries for nested objects, but I don't know how to invoke existing resolvers on an ......
Read more >Resolvers | NestJS - A progressive Node.js framework
In this approach, keep your models ( ObjectType classes), resolvers and services together within a Nest module representing the domain model.
Read more >Custom Value Resolvers - AutoMapper documentation
The default generated code for resolving a property, if you haven't customized the mapping for that member, generally doesn't have any problems. But...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The way errors get parsed is pretty much like get/set method.
test.test.test
to become
{test: {test: test{}}}
any update on this issue? or is there anything we can need to patch for resolver?