Skip to main content

Module util

Module util 

Source
Expand description

Shared utilities for code generation targets.

Functions§

reconstruct_operation
Reconstruct a GraphQL operation document string from the IR.
scalar_to_mock
Map a ScalarType to a sensible TypeScript mock default value.
to_hook_name
Convert an operation name to a hook name. e.g. “GetUser” -> “useGetUser”
to_method_name
Convert an operation name to a camelCase method name (lowercase first char). e.g. “GetUser” -> “getUser”, “CreatePost” -> “createPost”
to_mock_data_name
Convert an operation name to a mock data factory name. e.g. “GetUser” -> “mockGetUserData”
to_mock_error_name
Convert an operation name to a mock error handler name. e.g. “GetUser” -> “mockGetUserError”
to_mock_name
Convert an operation name to a mock handler name. e.g. “GetUser” -> “mockGetUser”
type_to_ts
Map a CompiledType to a TypeScript type string.
variable_to_graphql
Map GraphQL variable type to its GraphQL SDL string representation. e.g. required String -> “String!”, optional Int -> “Int”