Skip to content

Invalid schema sometimes generates an alias error #57

@jonurry

Description

@jonurry

If you pass in an undefined schema value to the generator then it fails to extract an alias and errors with the message:

TypeError: Cannot destructure property alias of 'undefined' or 'null'.

Also happens if you set a default value of null for an input.

To fix this in the generateInputSchema function in generateInputSchema.js:

change:

// deep map change keys to aliases
const aliasedSchema = deepMapKeys(mappedSchema, (key, value) => {
	const { alias } = value;
	return alias || key;
});

to

// deep map change keys to aliases
const aliasedSchema = deepMapKeys(mappedSchema, (key, value) => {
	const { alias } = value || {};
	return alias || key;
});

by adding || {} to const { alias } = value

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions