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

Since 2022.7.0 Insomnia cannot get schema from graphql api #5542

Closed
1 task done
Exifs opened this issue Dec 16, 2022 · 23 comments
Closed
1 task done

Since 2022.7.0 Insomnia cannot get schema from graphql api #5542

Exifs opened this issue Dec 16, 2022 · 23 comments
Labels
A-graphql Area: GraphQL Protocol B-bug Bug: general classification B-graphql-2022.7.0 Bug: Graphql issues 2022.7.0 N-investigation Needs: investigation S-unverified Status: Unverified by maintainer

Comments

@Exifs
Copy link

Exifs commented Dec 16, 2022

Expected Behavior

Insomnia should be able to get schema from introspection url and help with autocompletion.

Actual Behavior

Since the upate, my working query are now getting a 403 error while getting the schema.
But creating a GET HTTP request to the same url with /schema.json is working

Reproduction Steps

try to use a graphql query and use the auto schema fetching

Is there an existing issue for this?

Additional Information

Version: Insomnia 2022.7.0
Build date: 15/12/2022
OS: Windows_NT x64 10.0.22000
Electron: 22.0.0
Node: 16.17.1
V8: 10.8.168.20-electron.0
Architecture: x64

Insomnia Version

2022.7.0

What operating system are you using?

Windows

Operating System Version

windows 11

Installation method

downloaded from the websit and automagically updated

Last Known Working Insomnia version

2022.6.0

@Exifs Exifs added B-bug Bug: general classification S-unverified Status: Unverified by maintainer labels Dec 16, 2022
@filfreire filfreire added the A-graphql Area: GraphQL Protocol label Dec 16, 2022
@filfreire
Copy link
Member

@Exifs do you notice the same 403 errors if you try with another server (e.g. https://rickandmortyapi.com/graphql)

Can you also share error logs you see from Dev Console of Insomnia?

@filfreire filfreire added the N-investigation Needs: investigation label Dec 16, 2022
@Exifs
Copy link
Author

Exifs commented Dec 16, 2022

No, with this URL I get a 401 error.
The 403 error is probably due to authentication for my API, but the token used for that was correctly sent before.

@Exifs
Copy link
Author

Exifs commented Dec 16, 2022

After relading Insomnia with devtools activated, i got the following error message :
image

The only error i got in the logs is :
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:41.393 › [graphql] Failed to fetch schema Error: Request failed with status code 401

The call to the character query of the API is OK with the following logs :
15:09:31.021 › [network] Sending req=req_7ba138e07cee49578ea74738887d3d4d env=env_a32c895d747346d988325d013250a032
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:31.446 › [header] Set default header Authorization: Bearer XXXXXXXXXXXXXXXXTHISISMYAUTHTOKEN
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:31.540 › [network] Response failed req=req_7ba138e07cee49578ea74738887d3d4d err=Error: Failure when receiving data from the peer
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:34.345 › [network] Sending req=req_7ba138e07cee49578ea74738887d3d4d env=env_a32c895d747346d988325d013250a032
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:34.764 › [header] Set default header Authorization: Bearer XXXXXXXXXXXXXXXXTHISISMYAUTHTOKEN
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:35.254 › [network] Response succeeded req=req_7ba138e07cee49578ea74738887d3d4d status=200
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:37.183 › [network] Sending req=req_7ba138e07cee49578ea74738887d3d4d env=env_a32c895d747346d988325d013250a032
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:37.600 › [header] Set default header Authorization: Bearer XXXXXXXXXXXXXXXXTHISISMYAUTHTOKEN
\AppData\Local\insomnia\app-2022.7.0\resources\app.asar\node_modules@sentry\browser\dist\helpers.js:76 15:09:37.721 › [network] Response succeeded req=req_7ba138e07cee49578ea74738887d3d4d status=200

@phyllisstein
Copy link

I see the same thing. For example, I authenticate to a GraphQL API using an OAuth 2.0 client credentials grant. Insomnia correctly acquires and submits a token when I request the endpoint itself. However, from what I can see in the render log, it looks like schema requests, in particular, may drop the token on the floor.

[2022-12-16 11:32:42.802] [error] [graphql] Failed to fetch schema {
  message: 'Request failed with status code 401',
  name: 'Error',
  stack: 'Error: Request failed with status code 401\n' +
    '    at createError (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/core/createError.js:16:15)\n' +
    '    at settle (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/core/settle.js:17:12)\n' +
    '    at IncomingMessage.handleStreamEnd (/Applications/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/adapters/http.js:269:11)\n' +
    '    at IncomingMessage.emit (node:events:525:35)\n' +
    '    at endReadableNT (node:internal/streams/readable:1358:12)\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)',
  config: {
    url: 'https://tower.voxmedia.com/graphql',
    method: 'post',
    data: '{"query":"\\n    query IntrospectionQuery {}\\n  "}',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'axios/0.21.2',
      'Content-Length': 1774
    },

@colinshum
Copy link

colinshum commented Dec 16, 2022

+1, also seeing a 401 error after updating to 22.7.0. I've tested this using GitHub's GraphQL API, and confirmed that requests using the same token are making it through. Looks like this only affects schema introspection.

In the meantime, I've downgraded to release 22.6.0 and disabled automatic updates.

Logs:

helpers.ts:98 12:11:26.114 › [graphql] Failed to fetch schema Error: Request failed with status code 401
    at createError (/private/var/folders/32/hkfp424n2lj35x19733qclv80000gn/T/AppTranslocation/372FC57A-B846-4237-922B-4068E59DF5E1/d/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/private/var/folders/32/hkfp424n2lj35x19733qclv80000gn/T/AppTranslocation/372FC57A-B846-4237-922B-4068E59DF5E1/d/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/private/var/folders/32/hkfp424n2lj35x19733qclv80000gn/T/AppTranslocation/372FC57A-B846-4237-922B-4068E59DF5E1/d/Insomnia.app/Contents/Resources/app.asar/node_modules/axios/lib/adapters/http.js:269:11)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
sentryWrapped @ helpers.ts:98

@dlic-ddlucas
Copy link

+1 on 401 error, we use OAuth2, and this used to work with schema, but after upgrade it is like it ignored the authentication plugin and values and just fails. Even if I try manually it still fails. Just upgraded to 2022.7.0 this morning.

@cdn-schaars
Copy link

I can confirm that 2022.7.0 is not able to fetch the schema! A 401 error was displayed.
After finding this thread I downgraded to 2022.6.0
With this version the schema is fetched properly.
Kind regards,
Stefan

@viliam-jobko
Copy link

I used mitmproxy to sniff the Introspection query and found out that the HTTP Request header Authorization is missing. As mitigation, I disabled the Authentication option of Insomnia and specified the Authorization header manually.

@penngrove
Copy link

penngrove commented Dec 20, 2022

Yep, same problem here, our endpoint requires authentication and the introspection query does not use the authentication provided with the query (in our case HTTP Request Signature)

@dikuropiatnyk
Copy link

The same mistake for me, if I try to fetch Schema (and I'm using Bearer auth token) - 401.
But if send a "real" request to the /graphql endpoint, everything works great

@agm1981
Copy link

agm1981 commented Dec 21, 2022

Same here. We can no longer refresh the schema. We are using a fixed bearer token.
It was working fine before the latest version. Other queries still work.

@etooley
Copy link

etooley commented Dec 21, 2022

I'm seeing the same behavior with MacOS on M1. I am using OAuth 2.0 and the schema query fails with 401 while the actual graphql query succeeds.

@DawTaylor
Copy link

DawTaylor commented Dec 22, 2022

The Graphql introspection query is not being run with the current request authentication. Downgrading to 22.6.0 was the only way to get it working.

@kbumsik
Copy link

kbumsik commented Dec 22, 2022

I noticed the same thing. Since the latest update Insomnia starts dropping Authorization header for schema request. It works great for other requests like "Send" button.

@kofiasare
Copy link

kofiasare commented Dec 23, 2022

Downloaded 22.7.0 today and I am experiencing same. Downgrading to 22.6.0

@nikolayandr
Copy link

The same issue, schemas are not fetched at all, all my colleagues have similar issue

@nikolayandr
Copy link

nikolayandr commented Dec 28, 2022

Wow, I enabled automatic schema fetch, and it works now

UPD.
Sorry guys, my mistake @DawTaylor @skylersidner
image

@DawTaylor
Copy link

Wow, I enabled auth schema fetch, and it works now

I couldn't find that option.

@skylersidner
Copy link

skylersidner commented Dec 28, 2022

+1
Just downloaded 22.7.0 and lost my graphQL schema introspection.

I also can't figure out what @nikolayandr is referring to with, "enabling auth schema fetch"

@DawTaylor
Copy link

Wow, I enabled automatic schema fetch, and it works now

UPD. Sorry guys, my mistake @DawTaylor @skylersidner image

That didn't seem to help in my case. The introspection query still fails as the Authorization header is never sent.

@nikolayandr
Copy link

DawTaylor

In my case no Authorization is necessary so looks like it is enough to get schema fetching working after enabling automatic fetching

@DawTaylor
Copy link

So, it looks like there was a huge refactor on the packages/insomnia/src/ui/components/editors/body/graph-ql-editor.tsx file. On 2022.6.0 it used the packages/insomnia/src/network/network.ts to send the introspection query request, this network method injects the Authorization header based on the current request config, now it's using Axios instead without any of the "enhancements" that the network method does.

I'd love to try and push a fix for it, but I really don't have the bandwidth to do that at the moment.

core@2022.6.0...core@2022.7.0

@jackkav
Copy link
Contributor

jackkav commented Jan 4, 2023

We have a fix up at #5611 and it'll be in the next dot release, thanks for your patience.

@jackkav jackkav closed this as completed Jan 4, 2023
@filfreire filfreire added the B-graphql-2022.7.0 Bug: Graphql issues 2022.7.0 label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-graphql Area: GraphQL Protocol B-bug Bug: general classification B-graphql-2022.7.0 Bug: Graphql issues 2022.7.0 N-investigation Needs: investigation S-unverified Status: Unverified by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.