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

Failed to locate schema root node __schema #2719

Closed
hms-tuanpham opened this issue Nov 2, 2020 · 7 comments
Closed

Failed to locate schema root node __schema #2719

hms-tuanpham opened this issue Nov 2, 2020 · 7 comments
Labels
⌛ Waiting for info More information is required ❓ Type: Question

Comments

@hms-tuanpham
Copy link

hms-tuanpham commented Nov 2, 2020

Question.
My project: Android, compileSdkVersion 30, Kotlin language
Use:

  • classpath 'com.apollographql.apollo:apollo-gradle-plugin:2.4.1'
  • implementation("com.apollographql.apollo:apollo-runtime:2.4.1")

This is my schema.json file which I have downloaded from https://***/graphql:

{
  "_queryType": "Query",
  "_mutationType": "Mutation",
  "_subscriptionType": null,
  "_directives": [
    {
      "name": "model",
      "description": "collection in database",
      "locations": [
        "OBJECT"
      ],
      "args": [
        {
          "name": "filters",
          "description": "includes in filters",
          "type": "[String]"
        }
      ]
    },
    {
      "name": "input",
      "description": "convert to input",
      "locations": [
        "OBJECT"
      ],
      "args": [
        {
          "name": "ignores",
          "description": "ignore when create input",
          "type": "[String]"
        },
        {
          "name": "replaceWithId",
          "description": "replace with id",
          "type": "[String]"
        }
      ]
    },
    {
      "name": "cacheControl",
      "description": null,
      "locations": [
        "FIELD_DEFINITION",
        "OBJECT",
        "INTERFACE"
      ],
      "args": [
        {
          "name": "maxAge",
          "description": null,
          "type": "Int"
        },
        {
          "name": "scope",
          "description": null,
          "type": "CacheControlScope"
        }
      ]
    },
    {
      "name": "include",
      "description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
      "locations": [
        "FIELD",
        "FRAGMENT_SPREAD",
        "INLINE_FRAGMENT"
      ],
      "args": [
        {
          "name": "if",
          "description": "Included when true.",
          "type": "Boolean!"
        }
      ]
    },
    {
      "name": "skip",
      "description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
      "locations": [
        "FIELD",
        "FRAGMENT_SPREAD",
        "INLINE_FRAGMENT"
      ],
      "args": [
        {
          "name": "if",
          "description": "Skipped when true.",
          "type": "Boolean!"
        }
      ]
    },
    {
      "name": "deprecated",
      "description": "Marks an element of a GraphQL schema as no longer supported.",
      "locations": [
        "FIELD_DEFINITION",
        "ARGUMENT_DEFINITION",
        "INPUT_FIELD_DEFINITION",
        "ENUM_VALUE"
      ],
      "args": [
        {
          "name": "reason",
          "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",
          "type": "String",
          "defaultValue": "No longer supported"
        }
      ]
    },
    {
      "name": "specifiedBy",
      "description": "Exposes a URL that specifies the behaviour of this scalar.",
      "locations": [
        "SCALAR"
      ],
      "args": [
        {
          "name": "url",
          "description": "The URL that specifies the behaviour of this scalar.",
          "type": "String!"
        }
      ]
    }
  ],
  "astNode": null,
  "_typeMap": {
    "Query": "Query",
    "ID": "ID",
    "Qr": "Qr",
    "String": "String",
    "Entity": "Entity",
    "EventTimeline": "EventTimeline",
    "Html": "Html",
    "Event": "Event",
    "Date": "Date",
    "Loc": "Loc",
    "Int": "Int",
    "QrFilter": "QrFilter",
    "ListMetadata": "ListMetadata",
    "EventTimelineFilter": "EventTimelineFilter",
    "Mutation": "Mutation",
    "createQrInput": "createQrInput",
    "updateQrInput": "updateQrInput",
    "Boolean": "Boolean",
    "createEventTimelineInput": "createEventTimelineInput",
    "EventInput": "EventInput",
    "LocInput": "LocInput",
    "updateEventTimelineInput": "updateEventTimelineInput",
    "__Schema": "__Schema",
    "__Type": "__Type",
    "__TypeKind": "__TypeKind",
    "__Field": "__Field",
    "__InputValue": "__InputValue",
    "__EnumValue": "__EnumValue",
    "__Directive": "__Directive",
    "__DirectiveLocation": "__DirectiveLocation",
    "CacheControlScope": "CacheControlScope",
    "Upload": "Upload"
  },
  "_implementations": {}
}

When I build my Android project, the gradle throw an error:
Failed to parse GraphQL schema introspection query from
Failed to locate schema root node __schema

Please help me. I don't know why the schema.json is wrong?

@martinbonnin
Copy link
Contributor

martinbonnin commented Nov 2, 2020

Hi 👋 ! An introspection schema should have a __schema.types object which is not present in the above json so it looks like it's missing some information. See https://raw.githubusercontent.com/apollographql/apollo-android-tutorial/main/app/src/main/graphql/com/example/rocketreserver/schema.json for an exemple of a complete introspection schema.

If introspection is enabled on your endpoint, you can download a schema with the command below:

./gradlew downloadApolloSchema --endpoint=https://***/graphql --schema=app/src/main/graphql/com/example/schema.json

@hms-tuanpham
Copy link
Author

Hi @martinbonnin, Thank you very much.

@martinbonnin
Copy link
Contributor

Sure thing! Were you able to fix your issue? Do you mind if I close this ticket or can I help with anything else?

@martinbonnin martinbonnin added the ⌛ Waiting for info More information is required label Nov 2, 2020
@osmnnyldzz
Copy link

You just change ./gradlew to .\gradlew

Have a good days!

@shkhaider2015
Copy link

Hi 👋 ! An introspection schema should have a __schema.types object which is not present in the above json so it looks like it's missing some information. See https://raw.githubusercontent.com/apollographql/apollo-android-tutorial/main/app/src/main/graphql/com/example/rocketreserver/schema.json for an exemple of a complete introspection schema.

If introspection is enabled on your endpoint, you can download a schema with the command below:

./gradlew downloadApolloSchema --endpoint=https://***/graphql --schema=app/src/main/graphql/com/example/schema.json

Sir Where to run that command? In windows Powershell its not working.

@shkhaider2015
Copy link

Hi 👋 ! An introspection schema should have a __schema.types object which is not present in the above json so it looks like it's missing some information. See https://raw.githubusercontent.com/apollographql/apollo-android-tutorial/main/app/src/main/graphql/com/example/rocketreserver/schema.json for an exemple of a complete introspection schema.
If introspection is enabled on your endpoint, you can download a schema with the command below:

./gradlew downloadApolloSchema --endpoint=https://***/graphql --schema=app/src/main/graphql/com/example/schema.json

Sir Where to run that command? In windows Powershell its not working.

Thanks I change ./gradlew to .\gradlew and its fine in android terminal

@osmnnyldzz
Copy link

osmnnyldzz commented Jan 25, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌛ Waiting for info More information is required ❓ Type: Question
Projects
None yet
Development

No branches or pull requests

4 participants