graphql-engine
graphql-engine copied to clipboard
throw better error message when remote schema fails to load
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"}]}}}
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.
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.
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.
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 :)
Changing the title to reflect the same.
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://<IP address>:8080/v1/graphql
Any idea about the real reason of this issue? we are currently on v1.3.3
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
@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.
HASURA_GRAPHQL_ADMIN_SECRET
it doesn't help.. with all of the releses
@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 😃
Thank you @bastianwegge. That was indeed the case for us at least - the Authorization header.
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.