Q21: How do you implement a Custom Scalar in GraphQL?
When built-in primitives are insufficient, custom scalars (e.g., Date, JSON, URL) can be defined in SDL and provided custom logic for:
serialize: Converts back-end output to JSON.parseValue: Parses variables sent in JSON requests.parseLiteral: Parses inline AST literal values inside queries.
Key Takeaways
Custom scalars validate and transform specialized datatypes at the framework boundary.
Knowledge Check
Which custom scalar method parses inline literal values written directly inside a query string?