Bird
0
0

Which of the following is the correct way to declare a field of type ID in a GraphQL schema?

easy📝 Syntax Q12 of 15
GraphQL - Schema Definition Language (SDL)
Which of the following is the correct way to declare a field of type ID in a GraphQL schema?
AuserId: id
BuserId: Int
CuserId: String!
DuserId: ID!
Step-by-Step Solution
Solution:
  1. Step 1: Understand GraphQL type syntax

    Types are case-sensitive; ID must be uppercase and non-null indicated by !.
  2. Step 2: Check each option

    userId: ID! uses correct type 'ID!' with uppercase and non-null. Others are either lowercase or wrong type.
  3. Final Answer:

    userId: ID! -> Option D
  4. Quick Check:

    ID type is uppercase and non-null with ! [OK]
Quick Trick: ID type is uppercase and ! means non-null [OK]
Common Mistakes:
  • Using lowercase 'id'
  • Confusing ID with String
  • Omitting ! for required fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GraphQL Quizzes