Skip to content
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

graphql responses are now http 200 (fix #1368) #2064

Merged
merged 23 commits into from May 10, 2019
Merged

Conversation

ecthiender
Copy link
Member

@ecthiender ecthiender commented Apr 24, 2019

All graphql clients expect responses to be HTTP 200. Non-200 responses are considered transport layer errors. Changed all graphql responses in /v1/graphql endpoint to be 200.

Description

This change only works on the new endpoint: /v1/graphql. The behaviour of /v1alpha1/graphql remains the same.

Affected components

  • Server
  • Tests

Related Issues

#1368

Solution and Design

Steps to test and verify

  1. Make any wrong request to /v1/graphql endpoint
  2. It returns HTTP 200 status.

Limitations, known bugs & workarounds

Console changes are pending.
Have select tests for /v1alpha1/graphql over websocket

  All graphql clients expect responses to be HTTP 200. Non-200 responses
  are considered transport layer errors. Changed all graphql responses in
  **/v1/graphql** endpoint to be 200.

  TODO: run tests for both endpoints
@ecthiender ecthiender requested a review from 0x777 as a code owner April 24, 2019 14:41
@ecthiender ecthiender added c/server Related to server s/do-not-merge Do not merge this pull request to master labels Apr 24, 2019
@ecthiender ecthiender changed the title fix graphql responses to be http 200 (fix #1368) graphql responses are now http 200 (fix #1368) Apr 24, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 2e194ac deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-2e194ac

@netlify
Copy link

netlify bot commented Apr 25, 2019

Deploy preview for hasura-docs ready!

Built with commit 246ff07

https://deploy-preview-2064--hasura-docs.netlify.com

@ecthiender ecthiender removed the s/do-not-merge Do not merge this pull request to master label Apr 25, 2019
@hasura-bot
Copy link
Contributor

Review app for commit 7507cf2 deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-7507cf2

@hasura-bot
Copy link
Contributor

Review app for commit 8c34961 deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-8c34961

@hasura-bot
Copy link
Contributor

Review app for commit 9f1e04c deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-9f1e04c

rakeshkky
rakeshkky previously approved these changes Apr 26, 2019
Copy link
Member

@rakeshkky rakeshkky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0x777
Copy link
Member

0x777 commented Apr 30, 2019

@ecthiender Can you check the error response format for subscriptions for /v1/graphql?

  1. Are they as per the apollo-ws protocol?
  2. Are they consistent with the errors in http?

@shahidhk
Copy link
Member

shahidhk commented Apr 30, 2019

@0x777 You're right, subscription errors are not GraphQL compliant.

{
  "type": "error",
  "id": "1",
  "payload": {
    "path": "$.selectionSet.articles.selectionSet.id1",
    "error": "field \"id1\" not found in type: 'articles'",
    "code": "validation-failed"
  }
}

is what the response is right now. It should be:

{
  "type": "error",
  "id": "1",
  "payload": {
    "message": "field \"id1\" not found in type: 'articles'",
    "extensions": {
      "code": "validation-failed",
      "path": "$.selectionSet.articles.selectionSet.id1"
    }
  }
}

Need to run some more tests to confirm the behaviour.

@hasura-bot
Copy link
Contributor

Review app for commit 1db897a deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-1db897a9

@hasura-bot
Copy link
Contributor

Review app for commit d80356b deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-d80356b8

@hasura-bot
Copy link
Contributor

Review app for commit 979dc2d deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-979dc2db

  - /v1alpha1/graphql returns older response structure
  - /v1/graphql returns newer response structure
@hasura-bot
Copy link
Contributor

Review app for commit 41e581c deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-41e581c8

  - run all tests only for v1/graphql
  - run specific tests for v1alpha1/graphql to check error response
  structures
@hasura-bot
Copy link
Contributor

Review app for commit 1531ed9 deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-1531ed96

@@ -155,8 +163,17 @@ onConn (L.Logger logger) corsPolicy wsId requestHead = do
(BL.toStrict $ J.encode $ encodeGQLErr False qErr)

checkPath =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkPath should return ErrRespType. You don't have to look at paths twice.

@hasura-bot
Copy link
Contributor

Review app for commit eedc41f deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-eedc41f2

@hasura-bot
Copy link
Contributor

Review app for commit bd16413 deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-bd16413d

@hasura-bot
Copy link
Contributor

Review app for commit 246ff07 deployed to Heroku: https://hge-ci-pull-2064.herokuapp.com
Docker image for server: hasura/graphql-engine:pull2064-246ff076

@0x777 0x777 merged commit a21f6cd into hasura:master May 10, 2019
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-2064.herokuapp.com is deleted

polRk pushed a commit to polRk/graphql-engine that referenced this pull request Feb 12, 2020
Changes compared to `/v1alpha1/graphql`

* Changed all graphql responses in **/v1/graphql** endpoint to be 200. All graphql clients expect responses to be HTTP 200. Non-200 responses are considered transport layer errors. 

* Errors in http and websocket layer are now consistent and have similar structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/server Related to server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants