educative.io

Your examples are not working

Your example:
query {
viewer {
login
isHireable
name
location
status {
message
emoji
expiresAt
}
}
}
{
“data”: {
“viewer”: {
“login”: “mushketyk”,
“isHireable”: false,
“name”: “Ivan Mushketyk”,
“location”: “Dublin, Ireland”,
“status”: {
“message”: “Building a new course”,
“emoji”: “:hammer_and_wrench:”,
“expiresAt”: “2021-07-11T20:59:59Z”
}
}
}
}

this the out put:
{
“errors”: [
{
“message”: “Cannot query field “viewer” on type “Query”. Did you mean “Viewer”?”,
“status”: 400,
“locations”: [
{
“line”: 2,
“column”: 3
}
]
}
],
“data”: null
}

Hi @Mehmet_Beyaz !!
I’ve just tested this query on the GitHub GraphQL API explorer, and it’s providing me with the correct output. Could you please double-check it?
If you still face this error message that the GraphQL API is not recognizing the field “viewer” on the “Query” type then there could be a mismatch between the defined schema and the actual query.

There are a few potential reasons why you might be encountering this error:

  1. Case sensitivity: GraphQL is case-sensitive, so make sure you’re using the correct casing for the field names. In your case, “viewer” should be in lowercase.

  2. Authentication: Some GraphQL APIs require authentication to access certain fields or data. Make sure you are authenticated properly before running the query.

  3. API versioning: APIs sometimes introduce changes, including changes to the schema. It’s possible that the schema has been updated since my knowledge cutoff date in September 2021, and the query you’re using may no longer be valid in the current version of the API.

To resolve the issue, you can try the following steps:

  1. Double-check the casing of the field names. Ensure that “viewer” is in lowercase.

  2. Verify that you are properly authenticated and authorized to access the requested data.

  3. Check if there have been any recent changes or updates to the GraphQL API’s schema. Review the API documentation or changelog to ensure that your query aligns with the current schema.

I hope it helps. Happy Learning :blush: