PokeAPI / pokedex

PokeAPI's fork for adding gen-8 data.
https://github.com/PokeAPI/pokedex/tree/master-pokeapi/pokeapi
MIT License
43 stars 40 forks source link

GraphQL not working #132

Closed eroschagas closed 1 year ago

eroschagas commented 1 year ago

GraphQL is not working Fix plz ❤️

assiscs2 commented 1 year ago

Is it a general issue? I thought the problem was on my frontend, and it would be really weird, since i haven't really done anything on the project and started getting a cors related error: "Access to fetch at 'https://beta.pokeapi.co/graphql/v1beta' from origin 'http://localhost:3030' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

I have tried using a proxy such as cors-anywhere, but it didn't completely fix the problem.

I'm only able to query get a basic pokemon list, but after a couple of requests i get a 502 error, and i'm also unable to access individual pokemon data.

eroschagas commented 1 year ago

Is it a general issue? I thought the problem was on my frontend, and it would be really weird, since i haven't really done anything on the project and started getting a cors related error: "Access to fetch at 'https://beta.pokeapi.co/graphql/v1beta' from origin 'http://localhost:3030' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

I have tried using a proxy such as cors-anywhere, but it didn't completely fix the problem.

I'm only able to query get a basic pokemon list, but after a couple of requests i get a 502 error, and i'm also unable to access individual pokemon data.

It looks like a general issue! If you try to use the console it generates error as well https://beta.pokeapi.co/graphql/console/ It's very weird, if I try a query like this: query samplePokeAPIquery { pokemon_v2_pokemon { name id } } It works fine, but if I change id and name position or anything else, like this: query samplePokeAPIquery { pokemon_v2_pokemon { id name } } it returns an error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data Oh, and for the first query to work I have to prettify it! ¯\_(ツ)_/¯

Wilton-Garcia commented 1 year ago

The same here :(

Naramsim commented 1 year ago

Hi, restarted the container. Can you check?

eroschagas commented 1 year ago

Hi! It worked! Thank you very much!

assiscs2 commented 1 year ago

I'm getting the same error as before, I'm still quite new to this, but, a CORS error should be originated on the backend, right?

Is it a general issue? I thought the problem was on my frontend, and it would be really weird, since i haven't really done anything on the project and started getting a cors related error: "Access to fetch at 'https://beta.pokeapi.co/graphql/v1beta' from origin 'http://localhost:3030' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."

I have tried using a proxy such as cors-anywhere, but it didn't completely fix the problem.

I'm only able to query get a basic pokemon list, but after a couple of requests i get a 502 error, and i'm also unable to access individual pokemon data.

Also, using the samplePokeAPIquery on the API Explorer, I still get the same error as before SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

The only difference being that the reponse from the API seems to be taking a LOT longer, hence, delaying the error message.

I have tried restarting my application as well as clearing the cache in my browser to see if something could be causing a problem on the website, it did not have any effect.