-
-
Notifications
You must be signed in to change notification settings - Fork 451
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
Uncaught TypeError: Object(...) is not a function #206
Comments
Hiya, that's certainly odd! I apologise, we haven't announced v1 publicly for this very reason. We're still searching for good error messages that we can add here and there for more clarity. Do you have a small snippet at least of your usage of useQuery? A completely anonymised snippet would be completely fine! Feel free to comment out the actual query, variables, and component around it 👌 |
Sure!, I hope this is enough I start like this: import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from 'react-router-dom';
import Main from './pages/Main';
import * as serviceWorker from './serviceWorker';
import { Provider, createClient } from 'urql';
const gcProjectId = process.env.GC_PROJECT_ID;
const url = `https://api.graph.cool/simple/v1/${gcProjectId}`;
const client = createClient({
url,
fetchOptions: () => {
const token = window.localStorage.getItem("token");
return token
? {
headers: {
Authorization: `Bearer ${token}`
}
}
: {};
}
});
const App = () => (
<Provider value={client}>
<Router>
<Main />
</Router>
</Provider>
);
ReactDOM.render(<App />, document.getElementById('root'));
serviceWorker.unregister(); then I use it like this: import React from 'react';
import { Route } from 'react-router-dom';
import { useQuery } from 'urql';
import { Provider, createClient } from 'urql';
import asyncComponent from './../AsyncComponent';
import queries from './../queries';
import { DataProvider } from './../context';
const Dashboard = asyncComponent(() => import('./../pages/Dashboard'));
const Users = asyncComponent(() => import('./../pages/Users'));
const ActiveDoc = asyncComponent(() => import('./../pages/ActiveDoc'));
export default props => {
const query = queries.TotalQuery;
const [res] = useQuery({ query });
if (res.fetching || !res.data) {
return 'Loading...';
} else if (res.error) {
return `Oh no! ${res.error}`;
}
return <div>Stuff</div>;
}; |
I'm afraid it's hard to pin this down; your usage here looks correct and I'm unsure of how an error in urql would throw Also this doesn't seem to be mapping back to the actual file 🤔 Can you maybe check the line in
|
@sun2rise that kind of sounds like a dependency issue with GraphQL maybe? Given that it errors when calling "parse". We're using the same version on this repo for verification and testing, so maybe make sure that all dependencies are installed correctly and that your lockfile's integrity is good? It could also be a minification or bundling issue but those would be harder to pin down |
Hi @kitten, thanks for your support! This is the simplest project possible, as you will see. It works fine on codesandbox, but when I download the source and try locally it give the error. |
@kitten do you think that the codesandbox could help? does it work right on your host? |
Sorry for being inactive for a while! I've been caught up in a couple of other projects. I can successfully replicate your bug using the Sandbox as described (Export to zip, yarn, start, etc). If you upgrade |
We always parse the document now when we receive a string. This ensures a consistent request data structure and makes things easier, since there's not much else to expect. Also addresses a bug where `parse` is undefined. Fix #206
We always parse the document now when we receive a string. This ensures a consistent request data structure and makes things easier, since there's not much else to expect. Also addresses a bug where `parse` is undefined. Fix #206
We always parse the document now when we receive a string. This ensures a consistent request data structure and makes things easier, since there's not much else to expect. Also addresses a bug where `parse` is undefined. Fix #206
Hi,
as soon as I try to make a query I have this error:
It's strange because the same exact project inside codesandbox.io was working perfectly but now I have the same error in local and on netlify.
I cannot share this project, I'm sorry
I am using this (from
package.json
):The text was updated successfully, but these errors were encountered: