02 / 05

How to pass arguments to fields?

Difficulty: 5/10
field arguments, resolver args, input validation

The client must provide the required param value with the query:

Basic example:

Scenario Questions

0-2 years experience

  1. 1Suppose you need to fetch a list of books filtered by author name using GraphQL. How would you define the field and pass the author name as an argument in the query?
  2. 2If a client sends a query with a missing required argument for a field, what does the GraphQL server return and why?

2-5 years experience

  1. 1You added an optional `limit` argument to a `posts` field to support pagination, but the client reports that the server always returns all posts. Walk me through how you'd debug this.
  2. 2When you need to pass a complex filter object to a `searchProducts` field, what GraphQL schema constructs would you use and what trade‑offs do they have compared to multiple scalar arguments?

5-8 years experience

  1. 1Our service aggregates data from several micro‑services and exposes a GraphQL field that accepts a list of IDs. At high load we see the resolver receiving very large argument payloads causing latency spikes. How would you redesign the argument handling to mitigate this?
  2. 2Explain how you would enforce validation and authorization on field arguments in a large GraphQL API without scattering checks throughout every resolver.

8+ years experience

  1. 1We are migrating a legacy REST endpoint that accepted a JSON body with many optional parameters to a GraphQL API. What strategy would you use to map those parameters to field arguments while keeping backward compatibility and minimizing breaking changes?
  2. 2Across multiple teams, some services expose GraphQL fields with identical names but different argument signatures. How would you establish a governance model to standardize argument design and avoid client confusion at the organization level?

Follow-up Questions

  • Can you show a concrete schema snippet for the argument you described?
  • What does the server return if a required argument is omitted?
  • How would you test that argument validation works as expected?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.