Search code examples
reactjsgraphqlaws-appsync

How to send enum Type fields to GraphQL/AWS appsync from react


This is code section.. companyStatus: userCtx.user.category this section is generating error in the code. This field is actually enum type field in the schema.graphql Can anyone please help me how to write that section? companyName is working fine, but getting error from company Status.

ERROR : companyType has an invalid value, this is the error

var input = {
        companyName: userCtx.user.company,
        companyStatus: userCtx.user.status 
        createdAt: new Date().toISOString()
    }

Solution

  • I solved the issue. The code was all ok. My Schema was

    companyStatus {
    pending
    active
    inactive
    }
    

    In the code where I was receiving the enum value

    companyStatus: userCtx.user.status
    

    userCtx.user.status value was previously Pending, P in caps, so that was the issue. When I changes Pending to pending, it got solved. Thanks.