Reputation: 696
I keep geting this error:
Error: GraphQL error: Not Authorized!
Code is:
const queries = gql`
query {
mystreak
}
`;
render() {
return (
<Query query={queries}>
{({ loading, error, data }) => {
console.log(loading);
console.log(error);
console.log(data.mystreak);
}}
</Query>
)
}
App is built in React.js, and I am pretty new to GraphQL.
Also data is undefined.
Any ideas?
Thanks in advance
Upvotes: 3
Views: 23442
Reputation: 2624
I solved this issue by removing eas: projectId
from app.json
:
"extra": {
"eas": {
"projectId": "a1b2c3d4-e5f6-g7h8i9-j1k2-l3m4n5o6p7"
}
}
I need a build for development, the company's Expo project ID is different than my account's project ID, thus the problem...
Upvotes: 2
Reputation: 2138
I'm guessing you use Apollo. We are lacking a lot of information, especially regarding your backend, but it looks like you are missing an Authorization header in your http requests:
https://www.apollographql.com/docs/link/links/http.html#options
const link = createHttpLink({
uri: "/graphql",
headers: {
Authorization: 'Bearer <your token here>'
}
});
Check the documentation of your backend for the token value.
Upvotes: 4