Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: cannot represent value: ["open", "closed"] #115

Open
carloszimm opened this issue Oct 18, 2020 · 5 comments
Open

Error: cannot represent value: ["open", "closed"] #115

carloszimm opened this issue Oct 18, 2020 · 5 comments

Comments

@carloszimm
Copy link

carloszimm commented Oct 18, 2020

Hi, guys!
I've been trying to use this module in a project of mine that runs a express server, but for some reason the following error message always comes up:

GraphQLError [Object]: Enum "ElasticAPI72Enum_ExpandWildcards" cannot represent value: ["open", "closed"]

My code is practically the same as the one in the example.
I've already tried to downgrade (until the 5.8 version) and even upgrade the elasticsearch version but the message always shows up.
I'm using the 7.2 elasticsearch docker image (along with other images/containers with docker-compose).

Dependencies (related to the module) in the package.json:
"elasticsearch": "^16.0.0",
"graphql-compose": "^7.0.4",
"graphql-compose-elasticsearch": "^4.0.10"

The stacktrace:

/node_modules/graphql/type/definition.js:999
      throw new _GraphQLError.GraphQLError("Enum \"".concat(this.name, "\" cannot represent value: ").concat((0, _inspect.default)(outputValue)));
      ^

GraphQLError [Object]: Enum "ElasticAPI72Enum_ExpandWildcards" cannot represent value: ["open", "closed"]
    at GraphQLEnumType.serialize (/node_modules/graphql/type/definition.js:999:13)
    at astFromValue (/node_modules/graphql/utilities/astFromValue.js:136:27)
    at /node_modules/graphql-compose/lib/utils/definitionNode.js:307:80
    at Array.map (<anonymous>)
    at getArgumentsDefinitionNodes (/node_modules/graphql-compose/lib/utils/definitionNode.js:294:19)
    at /node_modules/graphql-compose/lib/utils/definitionNode.js:326:18
    at Array.map (<anonymous>)
    at getFieldDefinitionNodes (/node_modules/graphql-compose/lib/utils/definitionNode.js:315:21)
    at getObjectTypeDefinitionNode (/node_modules/graphql-compose/lib/utils/definitionNode.js:40:13)
    at ObjectTypeComposer.getType (/node_modules/graphql-compose/lib/ObjectTypeComposer.js:700:76)

Do you guys have any idea how to solve this issue?

Thanks

@rigobertocontreras
Copy link

@carloszimm I'm having the same issue I'm using

    "elasticsearch": "^16.7.1",
    "graphql": "^15.3.0",
    "graphql-compose": "^7.21.4",
    "graphql-compose-elasticsearch": "^4.0.10"

@slackday
Copy link

slackday commented Nov 2, 2020

I ran into this also. Seems a bit broken. I've managed to locate why the error occurs and it's because enum cannot be represented with two default values. Seems to have been this way through a lot of API-versions so there must have been some change in graphql-js or graphql-compose that broke this maybe.

I think the offending lines are here https://github.com/elastic/elasticsearch-js-legacy/blob/16.x/src/lib/apis/7_x.js#L3691-L3696

@slackday
Copy link

slackday commented Nov 2, 2020

I made a fork of elasticsearch-js-legacy and made some changes slackday/elasticsearch-js-legacy@dd327e2

This fixes the problem for me. If anyone else wanna give it a try change "elasticsearch": "^16.7.1", to "elasticsearch": "https://github.com/slackday/elasticsearch-js-legacy.git", in your package.json.

Elasticsearch seems to have released a new library for Node which looks like a re-write. Thus the "legacy" part in the library which graphql-compose-elasticsearch uses. I don't know if there's any point in doing a real PR.

Someone with more insight might be able to investigate this further and find the real issue.

@carloszimm
Copy link
Author

Yeah, @slackday. I was starting to suspect that the problem was somewhat related to that update and how it's handled in the graphql-compose-elasticsearch parser. I don't think you should open a PR, after all your fix should be more like a temporary fix until someone come up with some idea about how to fix the problem in the source code.

Additionally, I think the readme should be updated. Instead of pointing out that "Supported all elastic versions that support official elasticsearch-js client", where there is a link to the new elasticsearch client, the link should point to the legacy library hence indicating the de facto supported elastic versions (for the legacy library).

@krislander
Copy link

I'm still reproducing this issue. Is there by any chance a stable version.
Currently running
"elasticsearch": "^16.7.2"
"graphql-compose-elasticsearch": "^4.0.10",
"graphql-compose": "^7.24.2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants