hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.98k stars 2.75k forks source link

throw better error message when remote schema fails to load #4958

Open njaremko opened 4 years ago

njaremko commented 4 years ago

After upgrading to 1.2.2 I'm unable to add a remote schema (either with imported metadata, or adding through the console)

Here's the relevant metadata:

"remote_schemas": [
        {
            "name": "laravel-schema",
            "definition": {
                "url_from_env": "DEV_PORTAL_GRAPHQL_ENDPOINT",
                "timeout_seconds": 60,
                "headers": [
                    {
                        "value": "application/json",
                        "name": "Accept"
                    }
                ],
                "forward_client_headers": true
            }
        }
    ],
{"type":"metadata","timestamp":"2020-06-01T14:30:26.993+0000","level":"warn","detail":{"message":"Inconsistent Metadata!","info":{"objects":[{"definition":{"definition":{"timeout_seconds":60,"headers":[{"value":"application/json","name":"Accept"}],"url_from_env":"DEV_PORTAL_GRAPHQL_ENDPOINT","forward_client_headers":true},"name":"laravel-schema","comment":null},"reason":"Error in $: key \"data\" not found","type":"remote_schema"}]}}}
njaremko commented 4 years ago

This issue magically went away a couple hours later (with no changes to either my schema or the two Hasura schemas)...which is a little troubling, but I'll take the win. I'll leave this open in case someone at Hasura want's to take a look.

njaremko commented 4 years ago

This issue was affecting everyone on my team. It doesn't seem to happen when exporting and loading metadata through the cli tool, only when exporting and importing metadata through the console UI.

Needless to say, we're all using the CLI tool now, but probably a good idea to look into what's causing this.

tirumaraiselvan commented 4 years ago

The error "reason":"Error in $: key \"data\" not found" indicates that the introspection result (that Hasura performs when adding/reloading remote schema) did not succeed. This typically happens when the remote schema is down, network failures, timeouts and so on.

If you are noticing this consistently only in the console, then it's very strange and might require a repro for us to look at.

njaremko commented 4 years ago

Hmm, I'll get my team to do some more testing, but that could have been the reason.

This definitely needs a better error message :)

tirumaraiselvan commented 4 years ago

Changing the title to reflect the same.

milorad2020 commented 3 years ago

We are experiencing similar issue. We have existing remote schema added, however, the following error appears on console intermittently - "GraphQL Engine metadata is inconsistent with database". ... ... Reason: "HTTP exception occurred while sending the request to http://:8080/v1/graphql

Any idea about the real reason of this issue? we are currently on v1.3.3

image

cleivson commented 3 years ago

Just to complement that to me the problem of this "reason":"Error in $: key \"data\" not found" was that I was not passing the header with the hasura password of the remote schema, in case it helps anyone

manos-korakakis commented 2 years ago

@cleivson do you mean that you added the remote instance's HASURA_GRAPHQL_ADMIN_SECRET as part of the Additional headers when you create the remote schema? I am doing that but still getting the same error.

abushak commented 2 years ago

HASURA_GRAPHQL_ADMIN_SECRET

it doesn't help.. with all of the releses

bastianwegge commented 2 years ago

@manos-korakakis @abushak most APIs won't return an introspection query (that's the query you need to get all available fields) without an Authorization-Header. This Error generally indicates, that the introspection query failed. It's generally a good idea to ask specific questions to your error-case on StackOverflow rather than GitHub. If you provide more information on your specific use-case and your setup, one might be able to help 😃

manos-korakakis commented 2 years ago

Thank you @bastianwegge. That was indeed the case for us at least - the Authorization header.

meetzaveri commented 1 year ago

If you are not using it with auth webhook, or you have simply base level authentication i.e. hasura admin secret, then you need to pass that x-hasura-admin-secret header with your env value in to Additional headers section in remote schema form.