Skip to content

unsupported expression "auth.uid" #8643

@kauly

Description

@kauly

Operating System

Ubuntu

Environment (if applicable)

Nodejs 20

Firebase SDK Version

11.0.2

Firebase SDK Product(s)

DataConnect

Project Tooling

Nextjs

Detailed Problem Description

Im trying to integrate Firebase auth with data connect and according to the docs we can use the "auth.uid" directive but its not working on localhost with emulators. Also, it took me sometime to find the cause of the error because in the browser the error cause is "connector id not found".

Error:

I1117 12:31:32.449027   26009 control.go:45] [engine.Service /emulator/city-watch-data-connect 8955] UpdateSchema(): done sources: schema/schema.gql [333B] 
I1117 12:31:32.450023   26009 service.go:130] Failed to load latest connectors: connector/mutations.gql:10: mutation.AddOrder.order_insert (data.userId_expr: UUID_Expr): unsupported expression "auth.uid" (currently only "uuidV4()" is supported) 

Steps and code to reproduce issue

Mutation:

mutation AddOrder(
  $lat: Float!
  $lng: Float!
  $street: String
  $streetNumber: String
  $postalCode: String
  $neighborhood: String
  $observations: String
) @auth(level: USER) {
  order_insert(
    data: {
      userId_expr: "auth.uid"
      lat: $lat
      lng: $lng
      street: $street
      streetNumber: $streetNumber
      postalCode: $postalCode
      neighborhood: $neighborhood
      observations: $observations
    }
  )
}

Schema:

type User @table {
  username: String!
  auth: String @col(name: "user_auth") @default(expr: "auth.uid")
}

type Order @table {
  user: User
  lat: Float!
  lng: Float!
  street: String
  streetNumber: String
  postalCode: String
  neighborhood: String
  observations: String
  createdAt: Timestamp! @default(expr: "request.time")
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions