graphql-compose-elasticsearch
graphql-compose-elasticsearch copied to clipboard
Mappings with hyphens can't be parsed
If the ES mapping property name contains a hyphen, the service cannot start. Is there a workaround?
"comment-author-type": {
type: "text",
fields: {
keyword: {
type: "keyword",
ignore_above: 256
}
}
},
"errors": [
{
"message": "Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"comment-author-type\" does not.",
"stack": [
"GraphQLError: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but \"comment-author-type\" does not.",
" at isValidNameError (/Users/clint/Projects/chirp/node_modules/graphql/utilities/assertValidName.js:42:12)",
" at validateName (/Users/clint/Projects/chirp/node_modules/graphql/type/validate.js:199:53)",
" at validateInputFields (/Users/clint/Projects/chirp/node_modules/graphql/type/validate.js:439:5)",
" at validateTypes (/Users/clint/Projects/chirp/node_modules/graphql/type/validate.js:240:7)",
" at validateSchema (/Users/clint/Projects/chirp/node_modules/graphql/type/validate.js:54:3)",
" at /Users/clint/Projects/chirp/node_modules/express-graphql/index.js:97:66",
" at processTicksAndRejections (internal/process/task_queues.js:93:5)"
]
},
For now there is no mapping firlds with hyphens to camelCase.
There are two ways:
- change ES field name to camelCase
- dig lib code and open pull request
same error
@Zhouchuanwen Nope, this package cannot translate numeric field names to graphql field names. And I don't know any workaround for that. Except you rename fields according to graphql field name convention. Or write your own resolver from scratch without graphql-compose-elasticsearch.