question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting "undefined: undefined" when using enums

See original GitHub issue

I have a type-graphql class like this

import { registerEnumType } from 'type-graphql';

enum Color {
	black = 'black',
	white = 'white',
	gray = 'gray',
	orange = 'orange',
	purple = 'purple',
	red = 'red',
	yellow = 'yellow',
	green = 'green',
	blue = 'blue',
}

registerEnumType(Color, {
	name: 'Color', // this one is mandatory
	description: 'Various Colors', // this one is optional
});

@ObjectType()
class Grid {
        // ...
	@Field(() => [[Color]], { nullable: 'items' })
	colors?: (Color | null)[][];
        // ...
}

@Resolver(Sudoku)
export class GridResolver {
    @Query(() => [Grid])
    getGrids(): Grid[] {
    // return array of grids from db
    }
}

And I can successfully query it with the graphIQL playground. However when I query it with houdini like this

<script lang="ts">
    import { query, graphql, GetGrids } from '$houdini';

    const { data } = query<GetGrids>(graphql`
		query GetGrids {
			getGrids {
				colors
			}
		}
	`);
    console.log("data", $data);
</script>

I get

data {
    getGrids: [
        // ...
        { undefined: undefined }, // should be colors: ["green", ...]
        // ...
    ]
}

instead of the colors.

Am I doing something wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SorenHolstHansencommented, Aug 24, 2021

Thanks man!

1reaction
AlecAivaziscommented, Aug 24, 2021

This should be fixed in 0.10.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript runtime error: cannot read property of undefined ...
I want to import and use the enum in another class as such: import { RESTConfig, RESTMethod } from './RESTConfig'; class Pipelines ...
Read more >
Enum variables become undefined if changed to environment ...
Enums become undefined when input type is changed to an environment variable and then changed back to the static variable. When the variable...
Read more >
Enumeration declaration - cppreference.com
An enumeration is (re)declared using the following syntax: ... is not fixed and the source value is out of range, the behavior is...
Read more >
Some enums from a C++ namespace have undefined values ...
When I get undefined it is usually because I misspelled an enum or property. Does the above code actually reproduce the problem? Can...
Read more >
Guide - Enum TypeScript & JavaScript Tutorial
Without Enums in JavaScript, the coders came up with unique solutions. We can condense all of ... During runtime, it will just return...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found