Files
graphql-engine/community/tools/firebase2graphql/test/verifyRE1.js
Anon Ray a21f6cd648 introduce v1/graphql (fix #1368) (#2064)
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.
2019-05-10 11:35:10 +05:30

68 lines
1.9 KiB
JavaScript

const {query} = require('graphqurl');
const fetch = require('node-fetch');
const colors = require('colors/safe');
const complexQuery = `
query {
f2g_test_Authors (order_by: {Name:asc}) {
_id
Name
f2g_Articles (order_by: {Title:asc}, where: { IsUnpublished: { _eq: true}}) {
Title
f2g_test_Comments (order_by: {Date:asc}) {
Body
Date
}
}
}
}
`;
const verifyDataImport = () => {
query({
query: complexQuery,
endpoint: `${process.env.TEST_HGE_URL}/v1/graphql`,
headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
}).then(response => {
if (
response.data &&
response.data.f2g_test_Authors[0].f2g_Articles.length === 0 &&
response.data.f2g_test_Authors[1].f2g_Articles[0].f2g_test_Comments[0].Body === 'Comment1'
) {
let sqlString = '';
['Articles', 'Authors', 'Comments'].forEach(t => {
sqlString += `drop table public."f2g_test_${t}" cascade;`;
});
fetch(
`${process.env.TEST_HGE_URL}/v1/query`,
{
method: 'POST',
headers: {'x-hasura-admin-secret': process.env.TEST_X_HASURA_ADMIN_SECRET},
body: JSON.stringify({
type: 'run_sql',
args: {
sql: sqlString,
cascade: true,
},
}),
}
).then(() => {
console.log(colors.green('✔︎ data-sets/readme-example-1.json: Test passed'));
process.exit();
}).catch(() => {
process.exit();
});
} else {
console.log(colors.red('✖ data-sets/readme-example-1.json: Test failed. Unexpected response.'));
process.exit();
}
}).catch(e => {
console.log(colors.red('✖ data-sets/readme-example-1.json: Test failed. Unexpected response.'));
console.log(JSON.stringify(e, null, 2));
process.exit();
});
};
verifyDataImport();