Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
Using Uint8Array as an Argument for mutation in typegraphql

I need to save a public key to my postgres database from graphql. Using a Uint8Array seems the best option to save this with (let me know if you have a better suggestion). Therefore I have the entity:

@ObjectType()
@Entity()
export class Wallet extends BaseEntity {
  @Field()
  @PrimaryGeneratedColumn()
  id!: number;

  @Field()
  @Column({ type: 'bytea' })
  public_key!: Uint8Array;
}

And the resolver:

  @Mutation(() => User)
  async createUser(

    @Arg("email") email: string,
    @Arg("wallets", _type => [Uint8Array], { nullable: true }) wallets: Uint8Array[],
    @Ctx() { em }: MyContext
  ): Promise<User> {
    // input validation

    const user = {
      email: email,
      wallets: (wallets ? wallets.map(e => ({ 'public_key': e })) : [])
    }
    return { user: await em.save(User, user) };
  }

CannotDetermineGraphQLTypeError: Cannot determine GraphQL input type for argument named 'wallets' of 'createUser' of 'UserResolver' class. Is the value, that is used as its TS type or explicit type, decorated with a proper decorator or is it a proper input value?

I'm not sure I understand this error properly, can I not use Uint8Array as an input to my mutation or am I doing it incorrectly?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

GraphQL does not support binary types out of the box. It is recommended to use Base-64 encoded strings instead, which works well for small payloads. Read more: Binary in GraphQL

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda