⬡ GraphQL
Intermediate
What are custom scalars in GraphQL?
Answer
Custom scalars extend GraphQL beyond the five built-in scalar types to handle domain-specific primitive values. Common examples include Date (ISO 8601 string), DateTime, Email, URL, JSON, and UUID. You declare them in the schema: scalar Date, then implement the scalar in code with three methods: serialize (output coercion — how to send to client), parseValue (input coercion — how to parse from variable), and parseLiteral (how to parse from inline query literal). The graphql-scalars library provides production-ready implementations of dozens of common custom scalars.
Previous
How do you implement field-level authorization in GraphQL?
Next
What is the difference between Input types and Object types in GraphQL mutations?
More GraphQL Questions
View all →- Intermediate What is the N+1 problem in GraphQL and how does DataLoader solve it?
- Intermediate What are persisted queries in GraphQL?
- Intermediate What is the difference between schema-first and code-first GraphQL approaches?
- Intermediate What are the pagination strategies in GraphQL?
- Intermediate How is authentication handled in GraphQL?