openfga / sdk-generator

OpenFGA Client SDK Generator
Apache License 2.0
14 stars 30 forks source link

js-sdk: documentation incorrect regarding contextual tuples #346

Closed a0js closed 2 months ago

a0js commented 2 months ago

Checklist

Description

In all documentation on the OpenFGA site, and in the readme for the js-sdk, contextual tuples are added to check and list-objects methods using the contextual_tuples key. This key is ignored by the sdk as it is expecting contextualTuples. See https://github.com/openfga/js-sdk/blob/6e9b719c6b24aeff8e2124ae6abe2c48b2d38001/client.ts#L78 and https://github.com/openfga/js-sdk/blob/6e9b719c6b24aeff8e2124ae6abe2c48b2d38001/client.ts#L140 where the interfaces for the method bodies are declared.

You can view the documentation and see how the node sdk incorrectly shows that the contextual tuples should be referenced with contextual_tuples.

Expectation

Documentation should match the code.

Reproduction

  1. Spin up the following model in an OpenFGA instance:
    type user
    type object
    relations
        define test: [user]
  2. Run the following code against the server without adding any tuples:
    
    const { OpenFgaClient } = require('@openfga/sdk');
    const assert = require('assert');

const fgaClient = new OpenFgaClient({...}) // Details from your locally running fga instance

const {allowed} = await fgaClient.check({user: "user:test", relation: "test", object: "object:test", conditional_tuples:[{user: "user:test", relation: "test", object: "object:test"}]});

assert(allowed);


3. Notice the assertion fails.

### SDK Checklist

- [X] JS SDK
- [ ] Go SDK
- [ ] .NET SDK
- [ ] Python SDK
- [ ] Java SDK

### OpenFGA SDK version

0.3.5

### OpenFGA version

0.2.6

### SDK Configuration

any

### Logs

_No response_

### References

Due to company restrictions I cannot join the slack community to check if this question has been answered there. Sorry for lying on that check box.