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

Expression produces a union type that is too complex to represent #404

Open
lukepolo opened this issue Aug 8, 2024 · 0 comments
Open

Expression produces a union type that is too complex to represent #404

lukepolo opened this issue Aug 8, 2024 · 0 comments

Comments

@lukepolo
Copy link

lukepolo commented Aug 8, 2024

I ran into similar issues as

#189
#229

import { Chain, ValueTypes, ZeusScalars } from "../../generated/zeus";
import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { HasuraConfig } from "../configs/types/HasuraConfig";

const scalars = ZeusScalars({
  uuid: {
    decode: (value: string) => {
      return value;
    },
  },
  bigint: {
    encode: (value: string) => {
      return value.toString();
    },
    decode: (value: string) => {
      return value;
    },
  },
});

@Injectable()
export class HasuraService {
  private config: HasuraConfig;

  constructor(readonly configService: ConfigService) {
    this.config = configService.get<HasuraConfig>("hasura");
  }

  public async query<Z extends ValueTypes["query_root"]>(
    gql: Z | ValueTypes["query_root"],
  ) {
    try {
      return await this.getClient()("query", {
        scalars,
      })(gql);
    } catch (error) {
      if (error?.response) {
        throw error?.response.errors.at(0).message;
      }
      throw error;
    }
  }

  public async mutation<Z extends ValueTypes["mutation_root"]>(
    gql: Z | ValueTypes["mutation_root"],
    variables?: Record<string, unknown>,
  ) {
    try {
      return await this.getClient()("mutation", {
        scalars,
      })(gql, { variables });
    } catch (error) {
      if (error?.response) {
        throw error?.response.errors.at(0).message;
      }
      throw error;
    }
  }

  private getClient() {
    return Chain(`${this.config.endpoint}/v1/graphql`, {
      headers: {
        "Content-Type": "application/json",
        "x-hasura-admin-secret": this.config.secret,
      },
    });
  }
}

src/hasura/hasura.service.ts:50:7 - error TS2590: Expression produces a union type that is too complex to represent.

50       return await this.getClient()("mutation", {


         ~~~~~~

[3:03:31 AM] Found 2 errors. Watching for file changes.

Ive attached my shcema if that is helpful!

zeus.zip

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