openfga/sdk-generator

js-sdk: documentation incorrect regarding contextual tuples

Closed this issue · 0 comments

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Slack Community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

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]
  1. 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);
  1. Notice the assertion fails.

SDK Checklist

  • 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.