Fauna graphql will not let you re-use same FQL function for other customer resolvers

I created some resusable fql functions to use as main customer resolvers for all graphql endpoint.
==> i override all the default generated queries/mutation resolvers:

the below will not work.
==> fauna won’t let you reuse same fql function for other customer resolvers to other types.
==> fauna wont allow you to reuse same fql function for 2 different custom resolver references

is there any way i can make this work?

============================

type Mutation {

createUser(data: UserInput): User @resolver(name: “createcoreresolverfunction”)
updateUser(id: ID!, version: String!, data: UserInput!): User @resolver(name: “updatecoreresolverfunction”)
deleteUser(id: ID!, tn: String): User @resolver(name: “deletecoreresolverfunction”)

createCompany(data: CompanyInput): Company @resolver(name: “createcoreresolverfunction”)
updateCompany(id: ID!, version: String!, data: CompanyInput!): Company @resolver(name: “updatecoreresolverfunction”)
deleteCompany(id: ID!, tn: String): Company @resolver(name: “deletecoreresolverfunction”)

}

Hello @alex_doan and welcome! :wave:

You can call UDFs from UDFs. So if you want to reuse one, that’s the way to do it.

An important clarification about the GraphQL API is that the ID type knows nothing about what type or Collection it is for. Nor do the names of queries/mutations have any impact on how they work.

Typically for a custom resolver that takes an ID argument, you need to manually construct a Reference. That is easy enough because you understand the context of what query or mutation is being called.

CreateFunction({
  name: "create_user",
  role: Role("create_user_role"),
  body:  Query(Lambda(
    ["id", "data"],
    Call(
      Function("createcoreresolverfunction"),
      Ref(Collection("User"), Var("id")),
      Var("data")
    )
  ))
})

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.