Hint: Returned data matches requested fields exactly [OK]
Common Mistakes:
Assuming profile is null when data exists
Omitting nested profile field
Expecting error when schema is correct
4. Identify the error in this GraphQL schema for one-to-one relationship:
type User { id: ID! profile: [Profile] }
type Profile { id: ID! user: User }
medium
A. User type must not have profile field.
B. Using list syntax [Profile] for one-to-one relationship is incorrect.
C. Missing exclamation mark after Profile.
D. Profile type cannot reference User.
Solution
Step 1: Check field type for one-to-one
One-to-one means a single object, not a list. Using [Profile] means many profiles.
Step 2: Confirm correct syntax
Field should be profile: Profile without brackets for one-to-one.
Final Answer:
Using list syntax [Profile] for one-to-one relationship is incorrect. -> Option B
Quick Check:
List means many, not one [OK]
Hint: No brackets for one-to-one fields [OK]
Common Mistakes:
Confusing one-to-one with one-to-many
Adding unnecessary exclamation marks
Thinking references are not allowed
5. You want to model a one-to-one relationship between Author and Biography in GraphQL. Which schema design ensures each author has exactly one biography and each biography belongs to exactly one author?
hard
A. type Author { id: ID! name: String biography: Biography } type Biography { id: ID! text: String }
B. type Author { id: ID! name: String biographies: [Biography]! } type Biography { id: ID! text: String author: Author }
C. type Author { id: ID! name: String biography: Biography! } type Biography { id: ID! text: String author: Author! }
D. type Author { id: ID! name: String biographyId: ID! } type Biography { id: ID! text: String }
Solution
Step 1: Check for required one-to-one fields
Both Author and Biography have non-nullable fields pointing to each other, ensuring exactly one match.
Step 2: Validate mutual references
Each Author has one Biography! and each Biography has one Author!, enforcing one-to-one.
Final Answer:
type Author { id: ID! name: String biography: Biography! } type Biography { id: ID! text: String author: Author! } -> Option C
Quick Check:
Mutual non-null fields = strict one-to-one [OK]
Hint: Use non-null mutual fields for strict one-to-one [OK]
Common Mistakes:
Using lists instead of single objects
Making fields nullable allowing missing links
Not linking both types mutually
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.