amaster507
(Anthony Master)
January 22, 2021, 7:39pm
3
Is it possible to recieve args in myType? It doesnt seem to be working for me.
The Example given doesnt have it
But what I would like to do is:
type MyType {
...
customField(args:String) String @lambda
}
So that I can query like:
queryMyType {
customField(args: $args)
}
No, args work for @custom/@lambda query/mutation at present.
@custom/@lambda fields in types get only parents.
This is a feature request now instead of a bug, I just assumed this was already implemented from previous discussions around passing arguments into pre/post “hooks” for which lambda was developed.
A simple Javascript will look like this:
async getVirtualName({parent, graphql, args}) {
const [arg1, arg2] = args;
const data1 = await fetch(`https://external-data.com/some-data/${parent.id}`);
const data2 = await graphql(`query { foo { bar } }`);
return {...data1, ...data2 }
}
self.addEventListener("Query.getFullName", event => event.respondWith(getFullName(event)))
self.addEventListener("Mutation.updateName", event => event.respondWith(getFullName(event)))
self.addEventListener("User.virtualName", event => event.respondWith(getVirtualName(event)))
Alternatively, we can provide a function to get rid of the boiler plate at the end, but typescript will complain a bit
self.addGraphQLResolvers({
"Query.getFullName": getFullName,
"Mutation.updateName": updateName,
"User.virtualName": virtualName,
})