Bird
0
0

If a GraphQL schema defines a mutation like:

medium📝 query result Q5 of 15
GraphQL - Schema Definition Language (SDL)
If a GraphQL schema defines a mutation like:
type Mutation { addUser(name: String!): User }

What will happen if a client sends a mutation without the "name" argument?
AThe server ignores the mutation silently
BThe server returns an error about missing required argument
CThe mutation runs with a null name
DThe mutation adds a user with an empty string name
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of 'String!'

    The exclamation mark means the 'name' argument is required and cannot be null.
  2. Step 2: Predict server behavior on missing required argument

    If the client omits 'name', the server will reject the mutation with an error.
  3. Final Answer:

    The server returns an error about missing required argument -> Option B
  4. Quick Check:

    Required argument missing causes error = C [OK]
Quick Trick: Exclamation mark means argument is required [OK]
Common Mistakes:
  • Assuming server fills missing required args
  • Thinking null is accepted for required args
  • Believing mutation runs silently without errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes