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

Introspection Query Parse Error with Apollo GraphQL Schema Download #6327

Open
kibitheM opened this issue Dec 16, 2024 · 2 comments
Open

Introspection Query Parse Error with Apollo GraphQL Schema Download #6327

kibitheM opened this issue Dec 16, 2024 · 2 comments

Comments

@kibitheM
Copy link

Question

Hello There,

I'm encountering an issue while attempting to download a schema from my GraphQL endpoint using Apollo. I am working on integrating Apollo GraphQL with a Supabase project. Here's the configuration I'm using in my build.gradle.kts file:

apollo {
    service("service") {
        packageName.set("com.ngumi.app")
        srcDir("src/main/graphql")

        introspection {
            endpointUrl.set("https://peclvhlyxzwmegdkhtvj.supabase.co/graphql/v1
")
            headers.put("apikey", "<my-api-key>")
        }
         codegenModels.set("operationBased")
    }
}


When I run the following Gradle task:

./gradlew downloadApolloSchema

Bash
It fails with the following error:

Execution failed for task ':app:downloadApolloSchema'.
> java.lang.Exception: Introspection response from [https://<your-supabase-endpoint>](https://peclvhlyxzwmegdkhtvj.supabase.co/graphql/v1).supabase.co/graphql/v1 can not be parsed
Use code [with caution](https://support.google.com/legal/answer/13505487).
Debugging Steps Taken
To investigate further, I directly fetched the introspection query response from the server using Invoke-WebRequest in PowerShell. Here's the response I received:

{
    "errors": [
        {
            "message": "query parse error: Parse error at 1:787\nUnexpected `}[Punctuator]`\nExpected `end of input`\n"
        }
    ]
}


I also used the Apollo sandbox to run the introspection query, and it was successful and returned a full schema.

Additional Context
The GraphQL endpoint is functional, as I've successfully executed other queries through Postman and the Apollo sandbox.

The parse error suggests that there is an unexpected } character at the end of the introspection query being sent (Based on the error provided by my supabse endpoint).

Running the Gradle task with --info and --debug did not provide additional clarity beyond pointing to the parse error.

Questions
Is it possible that the introspection query generated by Apollo is malformed, or it is not compatible with the version of the GraphQL server that my Supabase endpoint is using? If so, where can I adjust it?

Are there any known issues with Apollo's handling of introspection queries on Supabase-hosted GraphQL endpoints?

Is there a way to customize or manually supply the introspection query used by Apollo? Or an alternative approach to downloading a schema when introspection is not possible?

I appreciate any help or guidance the team can provide! Please let me know if additional information is needed.

Thank you in advance for your support!
@BoD
Copy link
Contributor

BoD commented Dec 16, 2024

Thanks for reporting this.

This looks like an issue in Supabase. I've opened this ticket.

In the meantime, you can:

  1. execute the introspection query in Apollo Sandbox or Postman
  2. copy the JSON result
  3. paste it in your project in src/main/graphql/schema.json
  4. convert it to SDL with ./gradlew convertApolloSchema --from src/main/graphql/schema.json --to src/main/graphql/schema.graphqls
  5. delete schema.json

@kibitheM
Copy link
Author

Thanks for reporting this.

This looks like an issue in Supabase. I've opened this ticket.

In the meantime, you can:

  1. execute the introspection query in Apollo Sandbox or Postman
  2. copy the JSON result
  3. paste it in your project in src/main/graphql/schema.json
  4. convert it to SDL with ./gradlew convertApolloSchema --from src/main/graphql/schema.json --to src/main/graphql/schema.graphqls
  5. delete schema.json

Thank you for your response.

The suggested workaround is effective and allows me to proceed with the project while awaiting an official fix. I appreciate the clarification that this is a Supabase-related issue. Your assistance has been very helpful.

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

No branches or pull requests

2 participants