firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.86k stars 891 forks source link

unsupported expression "auth.uid" #8643

Open kauly opened 2 hours ago

kauly commented 2 hours ago

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")
}
google-oss-bot commented 2 hours ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.