apollo-client-devtools icon indicating copy to clipboard operation
apollo-client-devtools copied to clipboard

Dev Tools broken for anyone using `apollo-link-rest`

Open brentmclark opened this issue 7 years ago • 3 comments

Hello :)

I am introducing some of my coworkers to the fabulous DX of Apollo Client by showing them a complete setup using apollo-link-rest. There is not a graphql server at all; only a traditional REST API.

I believe that when the introspection query feature was introduced back in March the ability to use the dev tools for people like me — who are using ApolloClient exclusively for REST endpoints — broke. It now throws the following error:

TypeError: Cannot read property '__schema' of undefined

This is where I believe the problem was introduced:

https://github.com/apollographql/apollo-client-devtools/blob/master/src/devtools/components/Explorer/Explorer.js#L194

In it, there is no guard against an undefined result which is the outcome when getIntrospectionQuery failes to find a graphql server.

While I am quite capable of adding a guard around the code I linked, I have absolutely no idea what the downstream effects would be. Given my lack of familiarity with the codebase, It will take me a while to cut a PR for this. I will work on this in my spare time but be quite happy if someone more familiar with the project issued a fix for this issue faster than I am able.

🤞

brentmclark avatar Sep 17 '19 17:09 brentmclark

I was able to find a workaround for this by instantiating ApolloClient with typeDefs: {}

AllenAnthes avatar Sep 26 '19 12:09 AllenAnthes

Can confirm that fixed it for me, thanks @AllenAnthes

Daniel-Griffiths avatar Oct 25 '19 15:10 Daniel-Griffiths

This should no longer be an issue - thanks!

hwillson avatar Jan 31 '21 12:01 hwillson