4

I'm learning GraphQL now and I faced a problem that I am unable to resolve.

i have defined type in schema as

input School { name: String! exams: [subject!]! } input subject { name: String! mark: Number! }

But while running the server. I give data as "data": { "name":"varun", "exams":[], }

Server does not throw any validation error. Please suggest me solution. Is there any possible way to get validation error on passing exams as empty array.

I have tried alternate methods, but nothing works on schema level. I have to put a check explicitly to check exam field should not be an empty array. Thanks

1 Answers1

6

GraphQL cannot validate the length of a list. You need to include this validation logic as part of your resolver.

Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183