openfga / language

Grammar for the OpenFGA modeling language
https://openfga.dev
Apache License 2.0
17 stars 7 forks source link

feat: support use of module keyword #159

Closed ewanharris closed 7 months ago

ewanharris commented 7 months ago

Description

Adds support for the module keyword in the grammar, there's a couple things that I'm not 100% certain of (hence draft for feedback):

References

Closes #150, #151

Review Checklist

rhamzeh commented 7 months ago

We shouldn't be validating a partial model, only after all the pieces are collected can we validate

ewanharris commented 7 months ago

@rhamzeh I'm not sure I follow, are you saying that when processing modular models the intention is to construct the final model and then pass that to validateDSL rather than the individual model modules?

rhamzeh commented 7 months ago

when processing modular models the intention is to construct the final model and then pass that to validateDSL rather than the individual model modules?

Yes, the parser will handle validating the model syntactically, but you cannot validate it semantically, because it will need data from the other files.

E.g. user is not in that file, so validation will naturally fail until you have collected all the files in the model

ewanharris commented 7 months ago

So should validateDSL throw an error along the lines of cannot validate individual module if passed a module DSL?

ewanharris commented 7 months ago

@rhamzeh I've added a folder that represents the JSON<->DSL transform expected cases but have skipped it and the module name setting for now until we extend the AuthorizationModel definition to include the extra metadata we'll be adding