Collection: how to unique constraint for nested fields

How do I define a unique constraint on nested field? The following is throwing an invalid field path error:

collection Account {
    user: Ref<User>
    socialProvider: {
        name: "Github" | "Google" | "Facebook"
        userId: String
        email: String
    }?
    passkey: {
        publicKey: String
        algorithmId: Long
        passkeyId: String
    }?

    unique [.user, .socialProvider?.name]
    unique [.passkey?.passkeyId]
}
›   Error: error: Invalid field path
 ›   at src/lib/db/schema/fsl/collections/account.fsl:14:35
 ›      |
 ›   14 |     unique [.user, .socialProvider?.name]
 ›      |                                   ^^^^^^
 ›      |
 ›   error: Invalid field path
 ›   at src/lib/db/schema/fsl/collections/account.fsl:15:21
 ›      |
 ›   15 |     unique [.passkey?.passkeyId]
 ›      |                     ^^^^^^^^^^^
 ›      |

It would be also helpful if this topic would be covered directly in the docs: FSL collection schema: Unique constraint definitions - Fauna Docs

This looks like an issue with how we are handling the field path. Based on your schema, .passkey?.passkeyId is the correct path to use. That is, the type checking is correct.

We have an internal issue to prioritize and resolve this.

As a workaround, you should be able to provide a computed field and provide the unique constraint on that. Either way, this should require a unique value when one exists, but ignore it if the field resolves to null.

    compute passkeyId = (doc => doc.passkey?.passkeyId)
    unique [.passkeyId]