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
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2e194ac
fix all graphql responses to be http 200 (fix #1368)
ecthiender Apr 24, 2019
daed9e6
run all graphql tests on both graphql endpoints
ecthiender Apr 25, 2019
7507cf2
fix faulty test spec (did not have response key)
ecthiender Apr 25, 2019
8c34961
add docs
ecthiender Apr 25, 2019
9f1e04c
add v1/graphql/explain endpoint
ecthiender Apr 26, 2019
54badc9
Merge branch 'master' into fix-1368
shahidhk Apr 26, 2019
936493f
Merge branch 'master' into fix-1368
shahidhk Apr 30, 2019
1de10db
docs url changes
shahidhk Apr 30, 2019
f12ca6f
community content url changes
shahidhk Apr 30, 2019
aa5ba9f
install-manifests url changes
shahidhk Apr 30, 2019
a6bae57
Merge branch 'master' into fix-1368
shahidhk Apr 30, 2019
e65599b
Merge branch 'master' into fix-1368
shahidhk Apr 30, 2019
1db897a
fix tests
shahidhk Apr 30, 2019
ae72963
use graphql compliant errors in websocket
ecthiender May 2, 2019
d80356b
fix nested errors keys
shahidhk May 2, 2019
8010d0d
change response type for validation errors
shahidhk May 2, 2019
979dc2d
add start failed error
shahidhk May 3, 2019
41e581c
handle both graphql endpoints for websocket transport
ecthiender May 3, 2019
d2470ae
fix tests for v1alpha1/graphql and v1/graphql
ecthiender May 7, 2019
1531ed9
Merge branch 'master' of github.com:hasura/graphql-engine into fix-1368
ecthiender May 7, 2019
eedc41f
fix review comments and test
ecthiender May 8, 2019
bd16413
Merge branch 'master' into fix-1368
0x777 May 9, 2019
246ff07
Merge branch 'master' into fix-1368
0x777 May 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -56,7 +56,7 @@ Further reading: [Firebase SDK for Cloud Functions](https://firebase.google.com/
const idToken = await getIdToken()

const axios = axiosBase.create({
baseURL: 'https://YOURHASURADOMAIN/v1alpha1/graphql',
baseURL: 'https://YOURHASURADOMAIN/v1/graphql',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + idToken
Expand Down
Expand Up @@ -31,7 +31,7 @@ exports.handler = (event, context, callback) => {
body: "success"
};
const qv = {noteId: request.event.data.old.id, data: request.event.data.old.note};
fetch(hgeEndpoint + '/v1alpha1/graphql', {
fetch(hgeEndpoint + '/v1/graphql', {
method: 'POST',
body: JSON.stringify({query: query, variables: qv}),
headers: {'Content-Type': 'application/json', 'x-hasura-admin-secret': adminSecret},
Expand Down
Expand Up @@ -21,7 +21,7 @@ mutation updateNoteRevision ($noteId: Int!, $data: String!) {
exports.handler = async (event) => {
try {
const qv = { noteId: event.body.event.data.old.id, data: event.body.event.data.old.note };
const result = await fetch(hgeEndpoint + '/v1alpha1/graphql', {
const result = await fetch(hgeEndpoint + '/v1/graphql', {
method: 'POST',
body: JSON.stringify({ query: query, variables: qv }),
headers: { 'Content-Type': 'application/json', 'x-hasura-access-key': accessKey },
Expand Down
Expand Up @@ -4,7 +4,7 @@

ADMIN_SECRET = os.environ['ADMIN_SECRET']
HGE_ENDPOINT = os.environ['HGE_ENDPOINT']
HGE_URL = HGE_ENDPOINT + '/v1alpha1/graphql'
HGE_URL = HGE_ENDPOINT + '/v1/graphql'

HEADERS = {
'Content-Type': 'application/json',
Expand Down
Expand Up @@ -25,7 +25,7 @@ module.exports = function (context, req) {
const qv = {noteId: data.old.id, data: data.old.note};
const hgeResponse = query({
query: MUTATION_NOTE_REVISION,
endpoint: HGE_ENDPOINT + '/v1alpha1/graphql',
endpoint: HGE_ENDPOINT + '/v1/graphql',
variables: qv,
headers: {
'x-hasura-admin-secret': ADMIN_SECRET
Expand Down
Expand Up @@ -41,7 +41,7 @@ Edit `.env.yaml` and add values for the following as shown:
```yaml
# .env.yaml
GMAPS_API_KEY: '[GMAPS_API_KEY]'
HASURA_GRAPHQL_ENGINE_URL: 'http://[HGE_IP]/v1alpha1/graphql'
HASURA_GRAPHQL_ENGINE_URL: 'http://[HGE_IP]/v1/graphql'
```

```bash
Expand Down
Expand Up @@ -41,7 +41,7 @@ Edit `.env.yaml` and add values for the following as shown:
```yaml
# .env.yaml
GMAPS_API_KEY: '[GMAPS_API_KEY]'
HASURA_GRAPHQL_ENGINE_URL: 'http://[HGE_IP]/v1alpha1/graphql'
HASURA_GRAPHQL_ENGINE_URL: 'http://[HGE_IP]/v1/graphql'
```

```bash
Expand Down
Expand Up @@ -37,7 +37,7 @@ Execute `now` in this directory with an env var required for the code to execute
a mutation:

```bash
now -e HGE_ENDPOINT=https://my-app.herokuapp.com/v1alpha1/graphql
now -e HGE_ENDPOINT=https://my-app.herokuapp.com/v1/graphql
```

`HGE_ENDPOINT` is the Hasura GraphQL Engine endpoint.
Expand Down
Expand Up @@ -37,7 +37,7 @@ Execute `now` in this directory with an env var required for the code to execute
a mutation:

```bash
now -e HGE_ENDPOINT=https://my-app.herokuapp.com/v1alpha1/graphql
now -e HGE_ENDPOINT=https://my-app.herokuapp.com/v1/graphql
```

`HGE_ENDPOINT` is the Hasura GraphQL Engine endpoint.
Expand Down
Expand Up @@ -13,7 +13,7 @@ We use [dotenv](https://github.com/motdotla/dotenv) for setting environment vari
```
PORT=3000
NODE_ENV=development
GRAPHQL_ENDPOINT=http://localhost:8090/v1alpha1/graphql
GRAPHQL_ENDPOINT=http://localhost:8090/v1/graphql
HEADER_STRING='{}'
VARIABLE_STRING='{}'
QUERY_STRING='query { test_table { id } }'
Expand Down
Expand Up @@ -53,7 +53,7 @@ dataApisContent.push({
},
request: {
method: 'POST',
url: getUrl('/v1alpha1/graphql'),
url: getUrl('/v1/graphql'),
headers: defaultHeader,
bodyType: 'graphql',
params: JSON.stringify({}, null, 4),
Expand Down
Expand Up @@ -25,8 +25,8 @@ data:
without /graphql/console
}

proxy /graphql/v1alpha1/graphql hasura/v1alpha1/graphql {
without /graphql/v1alpha1/graphql
proxy /graphql/v1/graphql hasura/v1/graphql {
without /graphql/v1/graphql
websocket
}

Expand All @@ -44,7 +44,7 @@ data:

proxy /graphql/react react-apollo

proxy /graphql hasura/v1alpha1/graphql {
proxy /graphql hasura/v1/graphql {
without /graphql
websocket
}
Expand Down
@@ -1,9 +1,9 @@
This app uses environment variables.

```
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_CALLBACK_URL=http://localhost:3000/callback

Expand Down
@@ -1,9 +1,9 @@
This app uses environment variables.

```
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_CALLBACK_URL=http://localhost:3000/callback

Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/gatsby-postgres-graphql/README.md
Expand Up @@ -83,7 +83,7 @@ export const query = graphql`

- Run the app:
```bash
HASURA_GRAPHQL_URL=https://my-app.herokuapp.com/v1alpha1/graphql npm run develop
HASURA_GRAPHQL_URL=https://my-app.herokuapp.com/v1/graphql npm run develop
```
- Test the app
Visit [http://localhost:8000](http://localhost:8000) to view the app
Expand Down
Expand Up @@ -45,7 +45,7 @@ Ensure to configure Hasura GraphQL Engine with the environment variables `HASURA

```js
const httpLink = new HttpLink({
uri: 'https://myapp.herokuapp.com/v1alpha1/graphql', // Server URL (must be absolute)
uri: 'https://myapp.herokuapp.com/v1/graphql', // Server URL (must be absolute)
credentials: 'same-origin' // Additional fetch() options like `credentials` or `headers`
})
```
Expand Down
Expand Up @@ -29,7 +29,7 @@ function create (initialState) {
return forward(operation);
})
const httpLink = new HttpLink({
uri: 'https://my-app.herokuapp.com/v1alpha1/graphql', // Server URL (must be absolute)
uri: 'https://my-app.herokuapp.com/v1/graphql', // Server URL (must be absolute)
credentials: 'same-origin' // Additional fetch() options like `credentials` or `headers`
})
return new ApolloClient({
Expand Down
Expand Up @@ -47,7 +47,7 @@
connectToDevTools: process.browser,
ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
link: new HttpLink({
uri: 'https://myapp.herokuapp.com/v1alpha1/graphql', // Server URL (must be absolute)
uri: 'https://myapp.herokuapp.com/v1/graphql', // Server URL (must be absolute)
credentials: 'same-origin' // Additional fetch() options like `credentials` or `headers`
}),
cache: new InMemoryCache().restore(initialState || {})
Expand Down
Expand Up @@ -13,7 +13,7 @@ function create (initialState) {
connectToDevTools: process.browser,
ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
link: new HttpLink({
uri: 'https://myapp.herokuapp.com/v1alpha1/graphql', // Server URL (must be absolute)
uri: 'https://myapp.herokuapp.com/v1/graphql', // Server URL (must be absolute)
credentials: 'same-origin' // Additional fetch() options like `credentials` or `headers`
}),
cache: new InMemoryCache().restore(initialState || {})
Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/nextjs-postgres-graphql/README.md
Expand Up @@ -48,7 +48,7 @@ Boilerplate to get started with Nextjs, Hasura GraphQL engine as CMS and postgre
// can also be a function that accepts a `context` object (SSR only) and returns a config
const config = {
link: new HttpLink({
uri: 'https://my-app.herokuapp.com/v1alpha1/graphql', // <- Configure GraphQL Server URL (must be absolute)
uri: 'https://my-app.herokuapp.com/v1/graphql', // <- Configure GraphQL Server URL (must be absolute)
})
}

Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/nextjs-postgres-graphql/config.js
Expand Up @@ -3,7 +3,7 @@ import { HttpLink } from 'apollo-link-http'

const config = {
link: new HttpLink({
uri: 'https://hasura-graphql-2.herokuapp.com/v1alpha1/graphql', // <- Configure GraphQL Server URL (must be absolute)
uri: 'https://hasura-graphql-2.herokuapp.com/v1/graphql', // <- Configure GraphQL Server URL (must be absolute)
})
}

Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/nuxtjs-postgres-graphql/README.md
Expand Up @@ -49,11 +49,11 @@ columns: `id`, `title`, `content`, `author_id` (foreign key to `author` table's
export default function(context){
return {
httpLinkOptions: {
uri: 'https://my-app.herokuapp.com/v1alpha1/graphql',
uri: 'https://my-app.herokuapp.com/v1/graphql',
credentials: 'same-origin'
},
cache: new InMemoryCache(),
wsEndpoint: 'ws://my-app.herokuapp.com/v1alpha1/graphql',
wsEndpoint: 'ws://my-app.herokuapp.com/v1/graphql',
}
}
```
Expand Down
Expand Up @@ -2,10 +2,10 @@ import { InMemoryCache } from "apollo-cache-inmemory";
export default function(context){
return {
httpLinkOptions: {
uri: 'http://localhost:8080/v1alpha1/graphql',
uri: 'http://localhost:8080/v1/graphql',
credentials: 'same-origin'
},
cache: new InMemoryCache(),
wsEndpoint: 'ws://localhost:8080/v1alpha1/graphql',
wsEndpoint: 'ws://localhost:8080/v1/graphql',
}
}
Expand Up @@ -51,7 +51,7 @@ import VueApollo from 'vue-apollo'
import fetch from 'node-fetch'
import { createHttpLink } from 'apollo-link-http'

const httpLink = createHttpLink({ uri: 'https://myapp.herokuapp.com/v1alpha1/graphql', fetch: fetch })
const httpLink = createHttpLink({ uri: 'https://myapp.herokuapp.com/v1/graphql', fetch: fetch })

// Create the apollo client
const apolloClient = new ApolloClient({
Expand Down
Expand Up @@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo'
import fetch from 'node-fetch'
import { createHttpLink } from 'apollo-link-http'

const httpLink = createHttpLink({ uri: 'https://myapp.herokuapp.com/v1alpha1/graphql', fetch: fetch })
const httpLink = createHttpLink({ uri: 'https://myapp.herokuapp.com/v1/graphql', fetch: fetch })

// Create the apollo client
const apolloClient = new ApolloClient({
Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/react-apollo-todo/CONTRIBUTING.md
@@ -1,9 +1,9 @@
This app uses environment variables.

```
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_GRAPHQL_URL=https://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1alpha1/graphql
REACT_APP_REALTIME_GRAPHQL_URL=wss://hasura-todo-test.herokuapp.com/v1/graphql

REACT_APP_CALLBACK_URL=http://localhost:3000/callback

Expand Down
Expand Up @@ -6,10 +6,10 @@ const scheme = proto => {

export const GRAPHQL_URL = `${scheme(
"http"
)}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
)}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;
export const REALTIME_GRAPHQL_URL = `${scheme(
"ws"
)}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
)}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;
export const authClientId = "Fl-hdc6xdYIkok9ynbcL6zoUZPAIdOZN";
export const authDomain = "hasura-react-apollo-todo.auth0.com";
export const callbackUrl = `${scheme(
Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/react-static-graphql/README.md
Expand Up @@ -56,7 +56,7 @@ columns: `id`, `title`, `content`, `author_id` (foreign key to `author` table's

const client = new ApolloClient({
link: new HttpLink({
uri: 'https://myapp.herokuapp.com/v1alpha1/graphql',
uri: 'https://myapp.herokuapp.com/v1/graphql',
fetch
}),
cache: new InMemoryCache(),
Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/react-static-graphql/src/apollo.js
Expand Up @@ -5,7 +5,7 @@ import fetch from 'node-fetch'

const client = new ApolloClient({
link: new HttpLink({
uri: 'http://localhost:8080/v1alpha1/graphql', // replace this with your own Hasura GraphQL Endpoint
uri: 'http://localhost:8080/v1/graphql', // replace this with your own Hasura GraphQL Endpoint
fetch
}),
cache: new InMemoryCache(),
Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/realtime-chat-vue/src/vue-apollo.js
Expand Up @@ -12,11 +12,11 @@ import { split } from "apollo-link";
import VueApollo from "vue-apollo";
// Http endpoint
const httpLink = new HttpLink({
uri: "https://realtime-chat.demo.hasura.app/v1alpha1/graphql"
uri: "https://realtime-chat.demo.hasura.app/v1/graphql"
})

const wsLink = new WebSocketLink({
uri: "wss://realtime-chat.demo.hasura.app/v1alpha1/graphql",
uri: "wss://realtime-chat.demo.hasura.app/v1/graphql",
options: {
reconnect: true
}
Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/realtime-chat/src/index.js
Expand Up @@ -14,8 +14,8 @@ const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}
const HASURA_GRAPHQL_ENGINE_HOSTNAME = window.location.host;
export const GRAPHQL_ENDPOINT = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
export const WEBSOCKET_ENDPOINT = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
export const GRAPHQL_ENDPOINT = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;
export const WEBSOCKET_ENDPOINT = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;

// Make WebSocketLink with appropriate url
const mkWsLink = (uri) => {
Expand Down
Expand Up @@ -38,7 +38,7 @@ hosted on GitHub pages and the Postgres+GraphQL Engine is running on Postgres.
- Edit `HASURA_GRAPHQL_URL` in `src/constants.js` and set it to the
Heroku app URL:
```js
export const HASURA_GRAPHQL_URL = 'realtime-backend2.herokuapp.com/v1alpha1/graphql';
export const HASURA_GRAPHQL_URL = 'realtime-backend2.herokuapp.com/v1/graphql';
```
- Run the app (go to the root of the repo):
```bash
Expand Down
Expand Up @@ -8,8 +8,8 @@ const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}

const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;

const HASURA_LOCATION = {
lat: 12.93958,
Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/realtime-poll/src/apollo.js
Expand Up @@ -15,8 +15,8 @@ const scheme = (proto) => {
return window.location.protocol === 'https:' ? `${proto}s` : proto;
}

const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1alpha1/graphql`;
const wsurl = `${scheme('ws')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;
const httpurl = `${scheme('http')}://${HASURA_GRAPHQL_ENGINE_HOSTNAME}/v1/graphql`;

const wsLink = new WebSocketLink({
uri: wsurl,
Expand Down
2 changes: 1 addition & 1 deletion community/sample-apps/serverless-etl/README.md
Expand Up @@ -85,7 +85,7 @@ Use the `TRIGGER_URL` from previous step.
### Step 5: Add configuration variables

Edit `index.js` and add the following values:
- `HGE_URL`, your GraphQL Engine URL (ending with `v1alpha1/graphql`)
- `HGE_URL`, your GraphQL Engine URL (ending with `v1/graphql`)
- `APP_ID`, the algolia application id
- `SEARCH_KEY`, algolia search api key created in Step 2

Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/serverless-etl/index.js
Expand Up @@ -5,7 +5,7 @@ if (!("Notification" in window)) {

const screens = ['#loading-screen', '#input-screen', '#search-screen'];
// Replace with HGE_URL
const HGE_URL = '/v1alpha1/graphql';
const HGE_URL = '/v1/graphql';

function showScreen(name) {
for (screen of screens) {
Expand Down Expand Up @@ -69,7 +69,7 @@ $( document ).ready(function() {
}
});

$('#hge-console-link').attr('href', HGE_URL.replace('v1alpha1/graphql', 'console'));
$('#hge-console-link').attr('href', HGE_URL.replace('v1/graphql', 'console'));

showScreen('#input-screen');
$('#book-title').focus();
Expand Down
4 changes: 2 additions & 2 deletions community/sample-apps/serverless-push/index.js
Expand Up @@ -7,7 +7,7 @@ const messaging = firebase.messaging();
const screens = ['#loading-screen', '#permission-screen', '#input-screen', '#waiting-screen'];

// Replace with HGE_URL
const HGE_URL = '/v1alpha1/graphql';
const HGE_URL = '/v1/graphql';

function showScreen(name) {
for (screen of screens) {
Expand Down Expand Up @@ -149,5 +149,5 @@ $( document ).ready(function() {
}
});

$('#hge-console-link').attr('href', HGE_URL.replace('v1alpha1/graphql', 'console'));
$('#hge-console-link').attr('href', HGE_URL.replace('v1/graphql', 'console'));
});