ID
Unique identifier scalar type
Audience: Programmer
The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human-readable.
Format
Serialized as String
Not intended for human consumption
Must be unique within its type
Often UUIDs or database primary keys
Usage
type InventoryItem {
id: ID!
sku: String!
}
query {
inventoryItem(id: "550e8400-e29b-41d4-a716-446655440000") {
sku
}
}Best Practices
Always treat IDs as opaque strings
Never parse or manipulate ID values
Use for caching and refetching
Consider using UUIDs for distributed systems
See Also
UUID - Specific UUID scalar type
Node Interface - Interface requiring ID field
Last updated
Was this helpful?
