Comments (3)
Thanks @100ideas !
Hm, I think that's going to start causing problems for us somewhat. We can update the devtools, but we'll have to know and check the version of Apollo Client to know which option to use.
Actually... we can probably just pass both options, because currently Apollo Client just ignores options that it doesn't know about 🤔
@100ideas would you be willing to make a PR to make this change?
from apollo-client-devtools.
Tried hacking the Explorer component in Explorer.js to set fetchPolicy
instead of noFetch
, but I don't think this is working (still makes network requests if the query results haven't been cached?)
export default class Explorer extends Component {
constructor(props, context) {
super(props, context);
this.state = {
noFetch: true,
fetchPolicy: 'cache-only',
query: this.props.query,
variables: this.props.variables,
};
try {
evalInPage(
`
window.__APOLLO_CLIENT__.makeGraphiqlQuery = (payload) => {
return window.__APOLLO_CLIENT__.query({
query: payload.query,
variables: payload.variables,
fetchPolicy: payload.fetchPolicy,
}).catch(e => ({
errors: e.graphQLErrors,
}));
};
`, (result, isException) => {}
);
console.log(`Explorer.js constructor eval'd makeGraphiqlQuery w/ fetchPolicy: '${this.state.fetchPolicy}'`)
} catch(e) {
console.warn(e);
}
this.graphQLFetcher = (graphQLParams) => {
const { fetchPolicy } = this.state;
console.log("Explorer.js:graphQLFetcher fetchPolicy: " + fetchPolicy)
return createPromise(
"window.__APOLLO_CLIENT__.makeGraphiqlQuery(" + JSON.stringify({
operationName: graphQLParams.operationName,
query: parse(graphQLParams.query),
variables: graphQLParams.variables,
fetchPolicy: `'${fetchPolicy}'`
}) + ")"
);
};
}
componentDidMount() {
if (ga) ga('send', 'pageview', 'GraphiQL');
if (this.props.query) {
this.graphiql.handleRunQuery();
}
}
clearDefaultQueryState() {
this.setState({ query: undefined, variables: undefined });
}
render() {
const { noFetch } = this.state;
const graphiql = (
<GraphiQL
fetcher={this.graphQLFetcher}
query={this.state.query}
onEditQuery={() => { this.clearDefaultQueryState() }}
onEditVariables={() => { this.clearDefaultQueryState() }}
variables={this.state.variables}
ref={r => {this.graphiql = r}}
>
<GraphiQL.Toolbar>
<label>
<input
type="checkbox"
checked={noFetch}
onChange={() => {
let fetchPol = noFetch ? 'network-only' : 'cache-only';
this.setState({ noFetch: !noFetch, fetchPolicy: fetchPol, query: undefined, variables: undefined });
}}
/>
Load from cache
</label>
</GraphiQL.Toolbar>
</GraphiQL>
);
return <div className="body">{graphiql}</div>;
}
}
from apollo-client-devtools.
It's unlikely I'll spend time on this in the near future, but I will remember this thread if I do.
from apollo-client-devtools.
Related Issues (20)
- Finish Tailwind migration HOT 1
- Active queries disappear when used with RedwoodJS
- Dependency Dashboard
- Extension prevents websites (tested on atlassian.com) from loading styles HOT 9
- Not working! Apollo Client Devtools on Chrome latest HOT 17
- Doesn't work in latest Chromium-based MS Edge HOT 6
- Server side mutation errors are not reported in the explorer HOT 2
- Looking for client... No longer working after recent update HOT 16
- Impossible to track newly-created ApolloClients HOT 3
- Reactive Var Tab HOT 1
- Cache tab explodes causing the devtools to crash
- DevTools does not show any data for my app HOT 11
- Intermittent connection issues when first opening dev tools HOT 5
- unable to load devtool properly. Failed to execute 'postMessage' on 'Window' HOT 5
- v4.8.1 breaks Google Cloud Console on Arc & Chrome for Mac HOT 4
- Provide development apps that contains irregular cache data
- not show any data HOT 3
- Apollo Client Dev Tools get stuck HOT 3
- Extension causes query response handling to fail. Uncaught TypeError: Cannot convert object to primitive value HOT 6
- Serious memory leak issue with the devtools extension HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-client-devtools.