SpiceDB Schema Language Lexer/Parser
# spicedb
t
Hey all, potentially dumb question here, but would you guys happen to already have created a lexer or parser for the spicedb language defined over at https://authzed.com/docs/spicedb/concepts/schema ?
Here's my usecase- I have defined in a yaml file somewhere the baseline schema, which includes a whole bunch of definitions, assertions, etc. like:
Copy code
schema: |-
  definition user {}

  definition usergroup {
    relation manager: user | usergroup
    relation user: user | usergroup
    permission admin = manager
    permission member = user + manager
  }
relationships: |
<snip, some pre-populated relationships here>

assertions:
<snip, some assertions here>
Now, using the commandline I can actually apply this schema to my spicedb instance like so:
Copy code
zed import \
    --schema-definition-prefix=foo_prefix \
    --endpoint localhost:9998 \
    --token somerandomkeyhere \
    --insecure \  # Since its local
    --log-format json  src/main/resources/spicedb-schema.yml
this all works great and I have no problems here
j
t
however, in my application's start up code, I'm trying to run migrations automatically at startup, but since there is no prefix applied, my application ends up erroring out when trying to migrate since it tried to create things like
user
or
usergroup
instead of
foo_prefix/user
or
foo_prefix/usergroup
, so I essentially wrote my own poor mans parser, to inject in the prefix values manually and then calling the migrate commands
oh interesting, was the parser just a handmade one, and not one using a grammar or a parser generator like ANTLR or bison?
great reference point for me though, appreciate it!
j
it should be noted prefixes are only required on the serverless instance
t
Any chance I can get "Add in
prefix
field to the `SchemaService.WriteSchema`'s `WriteSchemaRequest`" (https://buf.build/authzed/api/docs/e2bb80cc596e435db4fd74d4299606f3:authzed.api.v1alpha1#authzed.api.v1alpha1.WriteSchemaRequest) added into your guys' bug backlog?
i'll still go ahead and just build out the java version of the parser you linked above anyways just to get unblocked, but figured I'd toss out a feature request to try and solve the original problem
106 Views