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

[Question]: How to download and use graphql/schema download #813

Open
1 task done
kibitheM opened this issue Dec 14, 2024 · 5 comments
Open
1 task done

[Question]: How to download and use graphql/schema download #813

kibitheM opened this issue Dec 14, 2024 · 5 comments
Labels
question Further information is requested supabase-issue

Comments

@kibitheM
Copy link

kibitheM commented Dec 14, 2024

General info

What is your question?

Hey Hello. I have intergrated apollo graphql to my supabase project using `val supabase = createSupabaseClient(
supabaseUrl = "https://id.supabase.co",
supabaseKey = "apikey"
) {
//...

install(GraphQL) {
    apolloConfiguration {
        // settings
    }
}

}`
I want to be able to use the schema from supabase so that I can be able to create queries from it. However I am unable to download the schema. I keep getting this error whenever I try to download

Cause: e: (unknown location): Invalid introspection schema '{"data": null, "errors": [{"message": "unexpected ': expected input should look like '{ "__schema": { "types": ...'

java.lang.Exception: Introspection response from https://myendpointurl.supabase.co/graphql/v1 can not be parsed

Iam very new to graphql and I don't know what to do from here and I have tried to look to see if I can find any online solution to no avail. Am I using the graphql in the wrong way? Do I need to perform any configuration or tweek any settings in the supabase dashboard? Must I download the schema to perform graphql queries? Iam so confused. Please any help will be greatly appreciated. Also, when I tried to run the endpoint in graphql sandbox, I got the response very well, meaning the endpoint is working correctly.

Here is also how I have configured the graphql in the build.gradle.kts file

`apollo {
service("service") {
packageName.set("src/main/graphql")
introspection {
endpointUrl.set("https://myendpointurl.supabase.co/graphql/v1")
headers.put("apikey", "myApiKey")
schemaFile.set(file("src/main/graphql/com/ngumi/app/schema.graphqls"))
}

}

}`

Relevant log output (optional)

Cause: e: (unknown location): Invalid introspection schema '{"data": null, "errors": [{"message": "unexpected ': expected input should look like '{ "__schema": { "types": ...'

Execution failed for task ':app:downloadServiceApolloSchemaFromIntrospection'.
> java.lang.Exception: Introspection response from https://myendpointUrl.supabase.co/graphql/v1 can not be parsed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 1s
1 actionable task: 1 executed
Configuration cache entry reused.
@kibitheM kibitheM added the question Further information is requested label Dec 14, 2024
@jan-tennert
Copy link
Collaborator

Invalid introspection schema '{"data": null, "errors": [{"message": "unexpected '

Indicates a error response. Can you read the full response?

@kibitheM
Copy link
Author

Invalid introspection schema '{"data": null, "errors": [{"message": "unexpected '

Indicates a error response. Can you read the full response?

Thanks for your help.

I managed to get the full response from the server using Invoke-WebRequest in PowerShell.

Here is the response:

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

It seems like the server is throwing a parse error. It is telling me that there is an unexpected } character, at the end of the introspection query we are trying to use, can you please help me with it?

Thanks again for your support, I appreciate it.

@jan-tennert
Copy link
Collaborator

Yea, I haven't seen this error, but I'm also not using GraphQL. This library only provides a pre-configured Apollo GraphQL Client, all other questions about usage problems are probably better asked in the Apollo GraphQL issues/discussions.
Let me know if you fixed your issue!

@kibitheM
Copy link
Author

Thank you.

Yea, I haven't seen this error, but I'm also not using GraphQL. This library only provides a pre-configured Apollo GraphQL Client, all other questions about usage problems are probably better asked in the Apollo GraphQL issues/discussions. Let me know if you fixed your issue!

Thank you. I have opened an issue there. Will let you know if I get a fix

@kibitheM
Copy link
Author

@jan-tennert
They have confirmed the issue and have opened up a ticket in supabase about it. The workaround has helped me in the meantime. Thank you once again.

Thanks for reporting this.

This looks like an issue in Supabase. I've opened supabase/supabase#31158.

In the meantime, you can:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested supabase-issue
Projects
None yet
Development

No branches or pull requests

2 participants