Apollo-android: Failed to locate schema root node `__schema`

Created on 2 Nov 2020  Â·  7Comments  Â·  Source: apollographql/apollo-android

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

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?

waiting for info Question

Most helpful comment

You just change ./gradlew to .\gradlew

Have a good days!

All 7 comments

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

Hi @martinbonnin, Thank you very much.

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

You just change ./gradlew to .\gradlew

Have a good days!

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.

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

Bro you should write below code in android studio terminal.

Shakeel Haider notifications@github.com, 18 Oca 2021 Pzt, 10:58 tarihinde
şunu yazdı:

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

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/apollographql/apollo-android/issues/2719#issuecomment-762059890,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AM67AQVSOBAIKR3QC7BVJGLS2PS37ANCNFSM4TG7WAVQ
.

Was this page helpful?
0 / 5 - 0 ratings