Bird
Raised Fist0
GraphQLquery~20 mins

Schema linting in GraphQL - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Schema Linting Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main purpose of schema linting in GraphQL?

Schema linting helps developers by:

  • A. Checking the schema for errors and style issues before deployment
  • B. Automatically generating queries from the schema
  • C. Running queries faster by optimizing the schema
  • D. Encrypting the schema for security
AChecking the schema for errors and style issues before deployment
BAutomatically generating queries from the schema
CRunning queries faster by optimizing the schema
DEncrypting the schema for security
Attempts:
2 left
💡 Hint

Think about what 'linting' usually means in programming.

query_result
intermediate
2:00remaining
What error will this GraphQL schema linting tool report?

Given this schema snippet:

type User { id: ID! name: String! age: Int }

The linting tool requires all fields to have descriptions. What is the linting error?

AMissing description for field 'age'
BMissing description for field 'name'
CMissing description for field 'id'
DNo errors found
Attempts:
2 left
💡 Hint

Check which fields lack descriptions.

📝 Syntax
advanced
2:00remaining
Which schema snippet will cause a linting syntax error?

Identify the schema snippet that will fail linting due to syntax issues:

Atype Query { user(id: ID!): User type User { id: ID! name: String! }
Btype Query { user(id: ID!): User } type User { id: ID! name: String! }
Ctype Query { user(id: ID!): User } type User { id: ID! name: String! age: Int }
Dtype Query { user(id: ID!): User } type User { id: ID! name: String! } enum Role { ADMIN USER }
Attempts:
2 left
💡 Hint

Look for missing braces or keywords.

optimization
advanced
2:00remaining
How can schema linting improve GraphQL API performance?

Choose the best explanation for how schema linting can indirectly improve API performance:

ABy automatically caching all queries defined in the schema
BBy encrypting schema fields to speed up data retrieval
CBy compressing the schema file size to reduce network load
DBy detecting inefficient schema designs that cause slow queries
Attempts:
2 left
💡 Hint

Think about how errors or bad designs affect query speed.

🔧 Debug
expert
3:00remaining
Why does this schema linting tool report a duplicate type error?

Given these schema definitions:

type Product { id: ID! name: String! } type Product { sku: String! price: Float! }

What is the cause of the linting error?

AThe 'Product' type is missing a description
BThe 'Product' type is defined twice with different fields
CThe 'Product' type fields have conflicting types
DThe schema is missing a Query type
Attempts:
2 left
💡 Hint

Check if type names are unique in the schema.

Practice

(1/5)
1. What is the main purpose of schema linting in GraphQL?
easy
A. To generate database tables automatically
B. To execute queries faster
C. To check the schema for mistakes and style issues
D. To encrypt data in the schema

Solution

  1. Step 1: Understand schema linting role

    Schema linting is used to find errors and style problems in GraphQL schemas.
  2. Step 2: Compare with other options

    Options B, C, and D describe unrelated tasks like query speed, database creation, or encryption.
  3. Final Answer:

    To check the schema for mistakes and style issues -> Option C
  4. Quick Check:

    Schema linting = check mistakes and style [OK]
Hint: Linting means checking code or schema for errors [OK]
Common Mistakes:
  • Confusing linting with query execution
  • Thinking linting creates database tables
  • Assuming linting encrypts data
2. Which of the following is a correct way to define a linting rule for a GraphQL schema?
easy
A. schemaLint: off
B. lintSchema = false
C. enableLinting = 0
D. "no-unused-types": true

Solution

  1. Step 1: Identify correct lint rule syntax

    Linting rules are usually defined as key-value pairs like "no-unused-types": true.
  2. Step 2: Check other options for syntax errors

    Options A, B, and D use invalid or incorrect syntax for linting rules.
  3. Final Answer:

    "no-unused-types": true -> Option D
  4. Quick Check:

    Lint rule syntax = key: value [OK]
Hint: Lint rules use key-value pairs like "rule-name": true [OK]
Common Mistakes:
  • Using assignment (=) instead of key-value pairs
  • Using invalid property names
  • Turning off linting with wrong syntax
3. Given this linting configuration snippet:
{
  "no-deprecated-fields": true,
  "require-description": true
}

What will happen if the schema uses a deprecated field without a description?
medium
A. Linting will pass without errors
B. Linting will report errors for both deprecated field and missing description
C. Linting will only check for missing descriptions
D. Linting will ignore deprecated fields

Solution

  1. Step 1: Analyze linting rules

    "no-deprecated-fields": true means deprecated fields cause errors. "require-description": true means missing descriptions cause errors.
  2. Step 2: Apply rules to schema case

    Schema has a deprecated field without description, so both rules trigger errors.
  3. Final Answer:

    Linting will report errors for both deprecated field and missing description -> Option B
  4. Quick Check:

    Both rules active = errors for both issues [OK]
Hint: Active lint rules cause errors for matching schema issues [OK]
Common Mistakes:
  • Assuming lint ignores deprecated fields
  • Thinking only one rule applies
  • Believing missing description is allowed
4. You run a schema linter and get an error: Field 'userAge' is missing a description. Which fix will resolve this error?
medium
A. Add a description string above the 'userAge' field in the schema
B. Rename the field to 'ageUser'
C. Remove the 'userAge' field from the schema
D. Ignore the error and continue

Solution

  1. Step 1: Understand the error meaning

    The error says the field lacks a description, so the linter expects a comment or description string.
  2. Step 2: Choose the fix that adds description

    Adding a description string above the field satisfies the linter. Renaming or removing the field or ignoring the error does not fix the missing description.
  3. Final Answer:

    Add a description string above the 'userAge' field in the schema -> Option A
  4. Quick Check:

    Missing description = add description [OK]
Hint: Add descriptions as comments to fix missing description errors [OK]
Common Mistakes:
  • Renaming field instead of adding description
  • Deleting field unnecessarily
  • Ignoring lint errors
5. You want to enforce that all GraphQL schema types have descriptions and no unused types exist. Which combined linting configuration achieves this?
hard
A. { "require-description": true, "no-unused-types": true }
B. { "allow-unused-types": true, "require-description": false }
C. { "no-deprecated-fields": true, "allow-unused-types": false }
D. { "require-description": false, "no-unused-types": false }

Solution

  1. Step 1: Identify rules for descriptions and unused types

    "require-description": true enforces descriptions. "no-unused-types": true disallows unused types.
  2. Step 2: Match configuration to requirements

    { "require-description": true, "no-unused-types": true } sets both rules to true, matching the goal. Other options disable one or both rules.
  3. Final Answer:

    { "require-description": true, "no-unused-types": true } -> Option A
  4. Quick Check:

    Both rules true = enforce descriptions and no unused types [OK]
Hint: Set both rules true to enforce descriptions and no unused types [OK]
Common Mistakes:
  • Disabling required rules
  • Confusing allow and no rules
  • Partial enforcement only