Skip to content

Change resolver parameters to follow Deno styling #42

@JIGutierrez

Description

@JIGutierrez

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions