GraphQL
GraphQL demand control
A valid GraphQL operation may still be unauthorized or too expensive. Resource-level access decisions belong in business logic, while demand controls limit how much work a request can ask the service to do. Apply both before expensive data access whenever possible. Do not disable introspection as the only security measure. Do not trust a complexity value supplied by a client. A rate limit on HTTP requests alone is insufficient if one request can perform much more work than another. Source: https://graphql.org/learn/security/ Local examples do not establish third-party integration support.
Formal Syntax & Structure
nodejs syntaxnodejs
depth, field cost, page-size and operation budgets (policy; not GraphQL syntax)Working Example
Example Snippetnodejs
const record={owner:'u1',title:'Private notes'};function title(principal, record) { return principal?.id === record.owner ? record.title : null;}console.log(title({id:'u1'},record));console.log(title({id:'u2'},record));console.log(title(null,record));