Spraypaint the isomorphic, framework-agnostic Graphiti ORM

Sparse Fieldsets

Use #select() to limit the fields returned by the server:

Post.select(['title', 'status']).all()

/posts?fields[posts]=title,status

When dealing with relationships, it may be easier to pass an object, where the key is the corresponding JSONAPI type. This will be exactly what’s sent to the server in ?fields:

Post.select({
  posts: ['title', 'status'],
  comments: ['created_at']
}).all()

/posts?fields[posts]=title,status&fields[comments]=created_at

Extra Fieldsets

Use #selectExtra() to explicitly request a field that doesn’t usually come back (often computationally expensive):

Post.selectExtra(['highlights', 'cumulative_ranking']).all()

/posts?extra_fields[posts]=highlights,cumulative_ranking

Just like the select example above, feel free to pass an object specifying the fields for each relationship.