Skip to content

Specifying enums in JSON #43

@kjellmorten

Description

@kjellmorten

Enums are defined though the EnumType class, in line with the conclusion on issue #2. Here's the example from the README:

const query = {
    query: {
        Posts: {
            __args: {
                orderBy: 'post_date',
                status: new EnumType('PUBLISHED')
            },
            title: true,
            body: true
        }
    }
};

However, this is problematic when I need to actually store this in a JSON file, where the EnumType won't be available. Here's a suggestion for an alternative way to define an enum:

{
    "query": {
        "Posts": {
            "__args": {
                "orderBy": "post_date",
                "status": { "__enum": "PUBLISHED" }
            },
            "title": true,
            "body": true
        }
    }
}

Would you be interested in a PR that implements this as an alternative to the EnumType, @vkolgi?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions