2

Whenever I import enums from graphql-codegen generated types and use their values, the app fails to start.

import { MyEnum } from 'graphql-types.ts';

let x: MyEnum; // This works
x = MyEnum.MY_ENUM_VALUE; // Whenever I use this code, it fails

TypeScript does not show any errors in the code, but the app fails to run showing the error message below.

Android Bundling failed

SyntaxError: graphql.types.ts: Identifier 'Document' has already been declared.

export const Document = gql`
...
5
  • 1
    have you tried naming your identifier as something other than Document? Commented Aug 5, 2022 at 19:49
  • @DamianGreen How are you able to change these identifiers? Commented Aug 5, 2022 at 20:12
  • `export const myQuery = gql`` Commented Aug 5, 2022 at 20:19
  • @DamianGreen That's what fixed it! If you create an answer, I will accept it. I needed to use: export const name = gql` query name ( instead of: export const name = gql` query ( Commented Aug 5, 2022 at 20:39
  • just saw this.. done :) Commented Aug 5, 2022 at 21:09

1 Answer 1

2

Use

export const name = gql`
    query name {

instead of:

export const name = gql`
    query {

Your identifier name is likely clashing with an ambient type definition.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.