I'm attempting to use the `queryPlanToPrisma` logi...
# help
m
I'm attempting to use the
queryPlanToPrisma
logic to convert a cerbos response to a prisma query and am running into some trouble. Auditing the call, the
planResources
call is returning something formed from --
Copy code
{
  "kind": "KIND_CONDITIONAL",
  "condition": {
    "expression": {
      "operator": "eq",
      "operands": [
        {
          "value": "qid::tenant:foo"
        },
        {
          "variable": "request.resource.attr.tenantQid"
        }
      ]
    }
  }
}
but then when I pass the result into
queryPlanToPrisma
with a pretty simple mapping
{ 'request.resource.attr.tenantQid': 'tenantQid'}
, I get filtering conditions that are
{ undefined: { equals: "undefined" } }
. I haven't gone too deep into the logic or tried other conditions, but was curious if I was doing something obviously wrong.
Perhaps some package version mismatch issue
If I mock the
planResources
call and play with the shape of the response I can get it to behave how I would expect. For example, this..
Copy code
condition: {
            operator: "eq",
            operands: [
              {
                name: "request.resource.attr.tenantQid",
              },
              {
                value: "qid::tenant:foo",
              }
            ]
          },
does give me this..
Copy code
Object {
  "tenantQid": Object {
    "equals": "qid::tenant:foo",
  },
}
a
Hey that's unexpected - let me look into this. What version of Cerbos and the adapter are you running?
Also which version of the JS SDk are you using?
m
Copy code
"@cerbos/grpc": "^0.7.0",
"@cerbos/orm-prisma": "^0.1.1",
"cerbos": "^0.4.0",
Really appreciate your help here 🙂 let me know if I can provide you with anything else
& using
<http://ghcr.io/cerbos/cerbos:latest|ghcr.io/cerbos/cerbos:latest>
a
@cerbos/grpc
is the correct SDK, the
cerbos
one is deprecated now. which are you using in your code? this is likely the culrpit
m
I'm using the
grpc
in the code, I just uninstalled
cerbos
and the output is the same
a
hmm, could you share the response from the
planResources
call?
we can move to DM if you don’t want to share it here
m
Sounds good -- I'll ping you there
a
Just in case anyone else is reading this, this issue has been fixed in
@cerbos/orm-prisma@0.1.2