dangcuuson / graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions
190 stars 36 forks source link

feat: add optionalResolverInfo option. #21

Closed baseonmars closed 5 years ago

baseonmars commented 5 years ago

Hi, I hope you'll accept this feature request and accompanying PR.

We're in the process of moving to using your schema generator and the option to leave out the info arg in the kinds of tests detailed below would be fantastic. We don't make use of info and we have many hundreds of resolver tests that follow the above format. I suspect there are others out there who would also find this useful.

This feature adds the option to generate resolver types with an optional info argument (the last argument of a resolver).

This option is useful for projects that do not make use of the info argument and want to simplifier their resolvers and their testing by omitting the parameter from their resolver function definitions.

e.g.:

const makeUser: MutationToUserResolver = async (parent, args, ctx) => {
  // ...
}
it("should do ensure username is over 8 characters", () => {
  const response = await makeUser(stubParent, genMakeUserArgs({username: "short"}), genCtx());
  // ...
});
dangcuuson commented 5 years ago

Hi there,

Sorry for the late reply. I have accept your PR & it should be published in v1.2.9

Cheers.

baseonmars commented 5 years ago

Thank you very much!