# Input argument validation

**URL:** <https://community.apollographql.com/t/input-argument-validation/8672>\
**Category:** Schema Design\
**Tags:** schema-design\
**Created:** [March 4, 2025, 7:27pm UTC](https://community.apollographql.com/t/input-argument-validation/8672 "2025-03-04T19:27:25Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![michaeldouglasdev](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michaeldouglasdev/32/4911_2.png) [@michaeldouglasdev](https://community.apollographql.com/u/michaeldouglasdev)\
**Post date:** [March 28, 2025, 6:40pm UTC](https://community.apollographql.com/t/input-argument-validation/8672/22 "2025-03-28T18:40:31Z")

</div>

I’m back with updates!

My previous implementation wasn’t working quite as expected, especially with nested fields. In those cases, the parent resolver was executed before input validation occurred in the nested fields, which wasn’t ideal for me. I want to validate all inputs first, regardless of whether they’re placed in nested fields or at the root, and only then execute the resolvers.

After experimenting, I found a better approach:  
I’m still using mapSchema to attach metadata, and I moved the validation logic into an Apollo Plugin, specifically in the `requestDidStart => didResolveOperation` lifecycle.

Why not `MapperKind.OBJECT_FIELD` or `INPUT_OBJECT_FIELD`?  
Well…

- `OBJECT_FIELD`: Runs the logic on **every field** , which technically works, but it means validating inputs multiple times per request. I don’t want this.  
Instead, it’s cleaner and more efficient to iterate through arguments just once at the beginning of the request via `requestDidStart`.
- `INPUT_OBJECT_FIELD`: it’s not possible to get data from both field at same time (start and end) and do the comparison. Each execution is independent.

I tried using `reflect-metadata` to create the metadata, but the `fieldConfig` reference was different between `mapSchema` and the Apollo Plugin. I’m not sure why, but `Reflect.getMetadata` was returning `undefined`, then I created my own metadata class using Map of Map

---

_[View the full topic](https://community.apollographql.com/t/input-argument-validation/8672)._
