I'm building a GraphQL API and in one of my endpoints I have this problem, it says that "message": "String cannot represent value: [\"Vitoria\", \"Serra\", \"Cariacica\", \"Vila Velha\"]".
I have tried to Change for type: GraphQLList.
const alfa_regions = [
{ES_capital: ['Vitoria', 'Serra', 'Cariacica', 'Vila Velha']},
{ES_Interior: ['Piuma', 'Sao Gabriel']},
{MG_Capital: ['Contagem']},
{MG_Interior: ['Juiz de fora', 'Governador Valadares', 'Teofilo Otoni', 'Monte Claros']},
]
const {
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
GraphQLFloat,
GraphQLList
} = graphql
const AlfaRegionType = new GraphQLObjectType({
name: 'AlfaRegion',
fields: () => ({
id: {type: GraphQLString},
region_id: {type: GraphQLString},
ES_capital: {type: GraphQLString},
})
})
const RootQuery = new GraphQLObjectType({
name: 'RootQueryType',
fields: {
regions: {
type: AlfaRegionType,
args: {id: {type: GraphQLString}},
resolve(parent, args){
return _.find(alfa_regions, {})
}
}
}
})