oak-graphql
oak-graphql copied to clipboard
Change resolver parameters to follow Deno styling
Currently, resolver functions have a format of:
const myResolver = (parent: any, data: any, ctx: any, info: any) => { ... }
According to the Deno Style Guide exported functions should have at most two parameters, which in this case, should be one argument and an options object. Due to the frequent use of the data parameter, I propose doing something like this:
interface resolverOptions: {
parent: any,
context: any,
info: any
};
const myResolver = (data: any, options: myResolver) => { ... }
This way, there will be no errors using deno lint (currently doesn't support custom flags), and will leave enough flexibility to use your own data interface, and extend the options interface to use your custom context (oak's RouterContext, for example).
Lastly, maybe the anys in the code could be changed to something safer? Perhaps Record<string, unknown> for data, not sure about the rest.
Thanks in advance :)
Currently, resolver functions have a format of:
const myResolver = (parent: any, data: any, ctx: any, info: any) => { ... }According to the Deno Style Guide exported functions should have at most two parameters, which in this case, should be one argument and an options object. Due to the frequent use of the data parameter, I propose doing something like this:
interface resolverOptions: { parent: any, context: any, info: any }; const myResolver = (data: any, options: myResolver) => { ... }This way, there will be no errors using
deno lint(currently doesn't support custom flags), and will leave enough flexibility to use your own data interface, and extend the options interface to use your custom context (oak's RouterContext, for example).Lastly, maybe the
anys in the code could be changed to something safer? PerhapsRecord<string, unknown>for data, not sure about the rest.Thanks in advance :)
Typo: options: myResolver should be options: resolverOptions
Is it possible to change this? It seems like that is matching the resolver signature coming from GQL.