Mark arguments as required in schema


Right now, required arguments, such as first on almost every connection aren’t marked as required in the schema. This means that GraphiQL doesn’t show a validation error while typing, and the query only fails after it’s sent to the server. The error returned is also non-standard for GraphQL, suggesting that it fails during execution, not validation.

If required arguments were used, GraphiQL could warn the user when they forget it.


@helfer This is actually a tricky one… We’re requiring clients to paginate, but unfortunately some of the pagination arguments are mutually exclusive. We require first or last, but there’s unfortunately no static way to represent that in a GraphQL schema. We’re definitely open to ideas on how to make this more clear in documentation or elsewhere.


Oh, right, good point! I think I might be able to put something together with schema decorators and a special validation rule. Would that be of interest to you?


We’d definitely be interested in seeing that. Thanks so much for taking an interest in this :smile:


instead of using first and last parameters with after and before how about using a scheme like take, cursor and direction : [BEGINNING | END] therefore take can be required, direction could be optional defaulting to BEGINNING and cursor would be optional to do the paging.


This is technically a possibility, but the Relay Specification details the first, last, before, and after arguments. I imagine we’ll want to implement that specification as closely as possible.


That would work with clients that support 100% of the GraphQL spec (e.g. Apollo Client), but it wouldn’t work with Relay, because Relay imposes some restrictions on the server schema, connection arguments being one of them.