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

introspectionQuery cant work #515

Closed
charlzyx opened this issue Oct 12, 2016 · 3 comments
Closed

introspectionQuery cant work #515

charlzyx opened this issue Oct 12, 2016 · 3 comments

Comments

@charlzyx
Copy link

Here is my code

var introspectionQuery = require('graphql/utilities').introspectionQuery;
var request            = require('sync-request');
var response = request('GET', graphqlHubUrl,{
    qs:{
        query: introspectionQuery
    }
});

I get an Error Module build failed: Error: Invalid introspection data supplied togetBabelRelayPlugin(). The resulting schema is not an object with a__schemaproperty.
then i check code and found something make this error
I test by http://graphql-swapi.parseapp.com/ and
https://www.graphqlhub.com/playground

//graphql-js/src/utilities/introspectionQuery.js
  query IntrospectionQuery {
    __schema {
      queryType { name }
      mutationType { name }
      subscriptionType { name }
      types {
        ...FullType
      }
      directives {
        name
        description
// HERE IS IT! the `locations` make query error , and delete this can work well
        locations
        args {
          ...InputValue
        }
      }
    }
  }

all query


  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
                }
              }
            }
          }
        }
      }
    }
  }

@stubailo
Copy link

Perhaps you're passing in an object that looks like { data: { __schema: ... } } and you just need to unwrap the data property?

@robzhu
Copy link
Contributor

robzhu commented Oct 14, 2016

Hey @ifelsee thanks for opening this issue! You're getting this error because you are executing a modern introspection query that asks for the locations field on the directive type, but the GraphQL servers you're hitting are running an older version from before the locations field was added.

We added support for directive locations here.

If you're just using these two GraphQL endpoints for testing and have control over your own GraphQL endpoint, upgrading to a newer version of GraphQL-js (>0.5.0) will support the locations field on directives. If this workaround is sufficient, please go ahead and close this issue.

We've deployed an updated SWAPI sample that should work with the introspection query you pasted: https://swapi-graphql.now.sh/. As for graphqlhub, there is already an open issue: clayallsopp/graphqlhub#37.

@charlzyx
Copy link
Author

@robzhu Very useful! Thank you for your answer

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

3 participants