Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Args and related module types in GraphQL Module Resolvers #5139

Open
Tracked by #8296 ...
tvvignesh opened this issue Nov 26, 2020 · 2 comments
Open
Tracked by #8296 ...
Assignees
Labels
core Related to codegen core/cli kind/enhancement New feature or request presets Related to Codegen presets

Comments

@tvvignesh
Copy link
Contributor

When I use the graphql-modules preset, I don't get typings like MutationCreateAuthMethodsArgs in the module generated file but I do get it in the overall codegen file

For eg: I have this in overall codegen file:

/** Auth Method Mutations */
export type MutationCreateAuthMethodsArgs = {
  input?: Maybe<Array<Maybe<CreateAuthMethodsInput>>>;
};

But not in the module file. I just have this:

export type createAuthMethodsInput = Pick<Types.CreateAuthMethodsInput, DefinedInputFields['createAuthMethodsInput']>;

I use the type in the provider like this:

async create(context: GraphQLModules.Context, args: GQLTypes.MutationCreateAuthMethodsArgs) {
}

but not able to do that now.

The typing works well in resolvers, but this is what I do in my resolver:

createAuthMethods: async (_parent, args, context: GraphQLModules.Context) => {
    let result = await context.injector.get(AuthMethod).create(context, args);
    return result;
  },

Thanks. Will use the global typed file as of now.

CC: @dotansimha

@dotansimha dotansimha added enhancement presets Related to Codegen presets labels Nov 26, 2020
@dotansimha dotansimha self-assigned this Nov 26, 2020
@tvvignesh
Copy link
Contributor Author

Also, while not related to this issue the context is not typed when using graphql modules preset. I get the type as any. Screenshot below:

1

@tvvignesh
Copy link
Contributor Author

One more thing which I wanted to share is that, I use DeepPartial to return a portion of the schema from my functions and I have it configured like this:

- add:
                  placement: prepend
                  content: >
                    import { DeepPartial } from 'utility-types';
            config:
              defaultMapper: DeepPartial<{T}>

Currently the import gets added to both the global and module generated types file (even though its not used in the module types file) because of which TS throws error (I run TS in strict mode)

1

Currently, I am overcoming this with a ts-ignore like this which is totally fine. But just thought I should let you know (sometime in the future, the ability to prepend content differently into the module types file and global types file would make sense:

content: >
   // @ts-ignore

  import { DeepPartial } from 'utility-types';

PS: This is not a priority.

@dotansimha dotansimha added kind/enhancement New feature or request and removed enhancement labels Jun 20, 2021
@charlypoly charlypoly added the core Related to codegen core/cli label Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli kind/enhancement New feature or request presets Related to Codegen presets
Projects
None yet
Development

No branches or pull requests

3 participants