Skip to content

TypeError thrown during introspectSchema #49

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

Closed
focusaurus opened this issue Dec 10, 2018 · 6 comments
Closed

TypeError thrown during introspectSchema #49

focusaurus opened this issue Dec 10, 2018 · 6 comments

Comments

@focusaurus
Copy link
Contributor

I am attempting to link our graphql-compose-elasticsearch API with another API via graphql-tools. I am not able to get the introspectSchema(link) call to succeed. It throws an exception which looks to be coming from the graphql-compose-elasticsearch response to the introspection query.

At one point I was able to reproduce the error with the query below, although at the moment this query is now running properly. That's why I'm confident the error is originating in graphql-compose-elasticsearch. However, the introspectSchema(link) call is still failing with the error below.

{
  __schema {
    types {
      inputFields {
        defaultValue
      }
    }
  }
}

That defaultValue seems to be the minimum case required to trigger the error. Here's the error I see in the response (value truncated beyond the interesting part)

{
  "errors": [
    {
      "message": "Float cannot represent non numeric value: \"The default grows with the number of nodes in the cluster but is at most 256.\"",
      "stack": [
        "TypeError: Float cannot represent non numeric value: \"The default grows with the number of nodes in the cluster but is at most 256.\"",
        "    at GraphQLScalarType.serializeFloat [as serialize] (/usr/local/src/node_modules/graphql/type/scalars.js:102:11)",
        "    at astFromValue (/usr/local/src/node_modules/graphql/utilities/astFromValue.js:144:27)",
        "    at resolve (/usr/local/src/node_modules/graphql/type/introspection.js:402:125)",
        "    at resolveFieldValueOrError (/usr/local/src/node_modules/graphql/execution/execute.js:479:18)",
        "    at resolveField (/usr/local/src/node_modules/graphql/execution/execute.js:446:16)",
        "    at executeFields (/usr/local/src/node_modules/graphql/execution/execute.js:293:18)",
        "    at collectAndExecuteSubfields (/usr/local/src/node_modules/graphql/execution/execute.js:717:10)",
        "    at completeObjectValue (/usr/local/src/node_modules/graphql/execution/execute.js:707:10)",
        "    at completeValue (/usr/local/src/node_modules/graphql/execution/execute.js:598:12)",
        "    at completeValue (/usr/local/src/node_modules/graphql/execution/execute.js:565:21)"
      ]
    }
  ],
  "data": {
    "__schema": {
      "types": [
        {
          "inputFields": null
        },
...
@focusaurus
Copy link
Contributor Author

While debugging this I managed to extract the actual graphql query that introspectSchema sends. I if send this to my API via graphiql I can reproduce the errors in the response which ultimately get thrown by introspectSchema.

    query IntrospectionQuery {
      __schema {
        queryType { name }
        mutationType { name }
        subscriptionType { name }
        types {
          ...FullType
        }
        directives {
          name
          description
          locations
          args {
            ...InputValue
          }
        }
      }
    }

    fragment FullType on __Type {
      kind
      name
      description
      fields(includeDeprecated: true) {
        name
        description
        args {
          ...InputValue
        }
        type {
          ...TypeRef
        }
        isDeprecated
        deprecationReason
      }
      inputFields {
        ...InputValue
      }
      interfaces {
        ...TypeRef
      }
      enumValues(includeDeprecated: true) {
        name
        description
        isDeprecated
        deprecationReason
      }
      possibleTypes {
        ...TypeRef
      }
    }

    fragment InputValue on __InputValue {
      name
      description
      type { ...TypeRef }
      defaultValue
    }

    fragment TypeRef on __Type {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
                ofType {
                  kind
                  name
                  ofType {
                    kind
                    name
                  }
                }
              }
            }
          }
        }
      }
    }

@nodkz
Copy link
Member

nodkz commented Dec 10, 2018

Live error
https://graphql-compose.herokuapp.com/elasticsearch/?query=%0Aquery%20IntrospectionQuery%20%7B%0A%20%20%20%20%20%20__schema%20%7B%0A%20%20%20%20%20%20%20%20queryType%20%7B%20name%20%7D%0A%20%20%20%20%20%20%20%20mutationType%20%7B%20name%20%7D%0A%20%20%20%20%20%20%20%20subscriptionType%20%7B%20name%20%7D%0A%20%20%20%20%20%20%20%20types%20%7B%0A%20%20%20%20%20%20%20%20%20%20...FullType%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20directives%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20description%0A%20%20%20%20%20%20%20%20%20%20locations%0A%20%20%20%20%20%20%20%20%20%20args%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20...InputValue%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20fragment%20FullType%20on%20__Type%20%7B%0A%20%20%20%20%20%20kind%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20description%0A%20%20%20%20%20%20fields(includeDeprecated%3A%20true)%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20description%0A%20%20%20%20%20%20%20%20args%20%7B%0A%20%20%20%20%20%20%20%20%20%20...InputValue%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20type%20%7B%0A%20%20%20%20%20%20%20%20%20%20...TypeRef%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20isDeprecated%0A%20%20%20%20%20%20%20%20deprecationReason%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20inputFields%20%7B%0A%20%20%20%20%20%20%20%20...InputValue%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20interfaces%20%7B%0A%20%20%20%20%20%20%20%20...TypeRef%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20enumValues(includeDeprecated%3A%20true)%20%7B%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20description%0A%20%20%20%20%20%20%20%20isDeprecated%0A%20%20%20%20%20%20%20%20deprecationReason%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20possibleTypes%20%7B%0A%20%20%20%20%20%20%20%20...TypeRef%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%0A%20%20%20%20fragment%20InputValue%20on%20__InputValue%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20description%0A%20%20%20%20%20%20type%20%7B%20...TypeRef%20%7D%0A%20%20%20%20%20%20defaultValue%0A%20%20%20%20%7D%0A%0A%20%20%20%20fragment%20TypeRef%20on%20__Type%20%7B%0A%20%20%20%20%20%20kind%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ofType%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D&operationName=IntrospectionQuery

Looks like that somwhere in elastic js package parsed incorrect default value via dox. Try to find 256. in elasticsearch package. I suppose that we should check default values according to type. For now such check is absent and it occurs the error.

PR welcome ;)

@nodkz
Copy link
Member

nodkz commented Dec 10, 2018

Here should be added additional check
https://github.com/graphql-compose/graphql-compose-elasticsearch/blob/master/src/ElasticApiParser.js#L325

@focusaurus
Copy link
Contributor Author

OK thank you for having a look and confirming. I will dig more into the code and see if I can send a PR.

@focusaurus
Copy link
Contributor Author

I think the page being parsed where the problematic data comes from is https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-search.html

focusaurus added a commit to focusaurus/graphql-compose-elasticsearch that referenced this issue Dec 10, 2018
focusaurus added a commit to focusaurus/graphql-compose-elasticsearch that referenced this issue Dec 10, 2018
@nodkz nodkz closed this as completed in f3b2b3c Dec 11, 2018
@nodkz
Copy link
Member

nodkz commented Dec 11, 2018

Fixed. A new version on npm already

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

2 participants