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

@gqlMutation with custom return type is incorrectly generated #1865

Open
Swahvay opened this issue Dec 17, 2024 · 0 comments
Open

@gqlMutation with custom return type is incorrectly generated #1865

Swahvay opened this issue Dec 17, 2024 · 0 comments

Comments

@Swahvay
Copy link
Contributor

Swahvay commented Dec 17, 2024

I have a custom GQL mutation:

@gqlMutation({
  class: 'RootResolver',
  name: 'loginWithApple',
  async: true,
  type: 'ThirdPartyLogin',
  args: [gqlContextType(), { name: 'identityToken', type: GraphQLString }],
})

With ThirdPartyLogin defined like this:

@gqlObjectType()
export class ThirdPartyLogin {
  constructor(token: string, newAccount: boolean) {
    this.token = token;
    this.newAccount = newAccount;
  }

  @gqlField({
    name: 'token',
    class: 'ThirdPartyLogin',
    type: GraphQLString,
  })
  token: string;

  @gqlField({
    name: 'newAccount',
    class: 'ThirdPartyLogin',
    type: GraphQLBoolean,
  })
  newAccount: boolean;
}

But then generated graphQL type is this:

export const LoginWithAppleType: GraphQLFieldConfig<
  undefined,
  RequestContext<BarnlogViewer>,
  LoginWithAppleArgs
> = {
  type: new GraphQLNonNull(LoginWithApplePayloadType), // offending line
  args: {
    identityToken: {
      description: '',
      type: new GraphQLNonNull(GraphQLString),
    },
  },
  resolve: async (
    _source,
    args,
    context: RequestContext<BarnlogViewer>,
    _info: GraphQLResolveInfo,
  ) => {
    const r = new RootResolver();
    return r.loginWithApple(context, args.identityToken);
  },
};

LoginWithApplePayloadType is not actually a thing. It should be

- type: new GraphQLNonNull(LoginWithApplePayloadType),
+ type: new GraphQLNonNull(ThirdPartyLoginType),

I believe this is only a problem with mutations as fields seem to handle this correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant