I’m new to FaunaDB and GraphQL. I followed this netlify.com blog article which includes creating users in Netlify Identity, and then storing some user info in FaunaDB, with an index to make Users findable via Netlify’s Identity ID. It went great:
So with the example running in the browser, a user is logged in via Netlify Identity, and then Netlify functions manage the actual interactions with FaunaDB. My understanding is that when using Netlify functions with Netlify Identity, the Netlify function is aware of which user is communicating with it via a JWT in a bearer token coming from the browser, which contains the Netlify ID.
I’d now like to update a user in Faunadb via GraphQL via a Netlify function (which the above guide does not cover). Uploading the schema to Faunadb automatically creates a mutation that lets me update a user via its Ref ID, but in the Netlify function I don’t have a ref ID, I have a Netlify Identity ID. I’m trying to figure out the best way to be able to update the user given the Netlify ID. Some possibilities I’ve thought of include:
- Create the additional custom mutations myself in the schema – which I’d like to avoid if possible
- Setting the User’s Ref ID to be the Netlify ID, which seems to be possible using FQL but I can’t figure out if there’s a way to do it via GraphQL
- Storing Faunadb’s Ref ID number as custom data in Netlify Identity when the User is created, which would then also be available to the Netlify function
- Making a separate GraphQL call first to retrieve the Ref ID, which is not ideal because then there are multiple calls when it seems like there should just be one
So none of these possible solutions seem great, but I guess #3 would be the simplest. But, is there something else you’d recommend, or something I’m missing?