0
0
GraphQLquery~20 mins

Schema visibility control in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Schema Visibility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of querying a hidden field?

Consider a GraphQL schema where the field secretInfo is marked as hidden using schema visibility control. What will be the result when a client queries secretInfo?

GraphQL
query {
  secretInfo
}
AThe query returns an error indicating <code>secretInfo</code> does not exist.
BThe query returns the value of <code>secretInfo</code> as normal.
CThe query returns <code>null</code> for <code>secretInfo</code> without error.
DThe query returns all fields except <code>secretInfo</code> silently.
Attempts:
2 left
💡 Hint

Think about how schema visibility hides fields from clients.

🧠 Conceptual
intermediate
1:30remaining
Why use schema visibility control in GraphQL?

Which of the following is the main reason to use schema visibility control in a GraphQL API?

ATo improve query performance by caching hidden fields.
BTo allow clients to modify the schema dynamically.
CTo automatically generate documentation for all fields.
DTo restrict access to sensitive fields based on client roles.
Attempts:
2 left
💡 Hint

Think about controlling what clients can see.

📝 Syntax
advanced
2:30remaining
Identify the correct way to hide a field in GraphQL SDL

Given the following GraphQL SDL snippet, which option correctly hides the internalNotes field using a directive @hidden?

GraphQL
type Product {
  id: ID!
  name: String!
  internalNotes: String @hidden
}
A
type Product {
  id: ID!
  name: String!
  internalNotes: String @hidden
}
B
type Product {
  id: ID!
  name: String!
  internalNotes: String @private
}
C
type Product {
  id: ID!
  name: String!
  internalNotes: String hidden
}
D
type Product {
  id: ID!
  name: String!
  internalNotes: String #hidden
}
Attempts:
2 left
💡 Hint

Directives start with @ in SDL.

optimization
advanced
2:00remaining
How does schema visibility control improve API security?

Which of the following best explains how schema visibility control enhances security in a GraphQL API?

ABy limiting the number of queries a client can send per minute.
BBy preventing clients from discovering and querying sensitive fields.
CBy automatically validating all input data types.
DBy encrypting all data sent over the network.
Attempts:
2 left
💡 Hint

Think about what clients can see in the schema.

🔧 Debug
expert
3:00remaining
Why does this query fail when using schema visibility control?

Given a GraphQL schema where the adminNotes field is hidden for non-admin users, a non-admin client runs this query:

query {
  product(id: "123") {
    id
    name
    adminNotes
  }
}

Why does this query fail?

ABecause the query syntax is invalid due to missing brackets.
BBecause the <code>product</code> type does not have an <code>adminNotes</code> field at all.
CBecause <code>adminNotes</code> is not visible in the schema for this client, causing a validation error.
DBecause the client does not have permission to query <code>id</code> and <code>name</code> fields.
Attempts:
2 left
💡 Hint

Consider what happens when a field is hidden from a client.