a8m / rql

Resource Query Language for REST
MIT License
343 stars 42 forks source link

expose fields #48

Closed ashtonian closed 1 year ago

ashtonian commented 1 year ago

includes https://github.com/a8m/rql/pull/47

This adds functions to expose the internal fields object and to create a new parser from a slice of field objects. This lets the user dynamically configure a parser, my use case is to change rql config based on permissions. I would also like to expose the parsed data and related field information to be able to document related metadata for the user like what are available operations.

I think it would be nice to refactor to the following, but this is breaking:

func NewParser(c Config, Model interface{}){}
func NewParserF(c Config,  fields []*Fields){}

Added:

func NewParserF(c Config, fields []*Field) (*Parser, error) {}
func (p *Parser) GetFields() []*Field {}