mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
console: fix gql try it button
This PR fix the issue with `GraphIQL Try` button. The issue is when we create a new schema other then public and try the gql operation using the `GraphIQL Try` button, it give the query and all but the query field is just only table name not the schemaName_table name so it will give me an error saying that query_field doesn’t exist [Slack thread](https://hasurahq.slack.com/archives/CKATHV1J7/p1667214392972649?thread_ts=1667202504.721889&cid=CKATHV1J7) PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6635 GitOrigin-RevId: e1403db0c3e63d88d2380fe1137137329910f990
This commit is contained in:
parent
1538490bdd
commit
bb0b95dd77
@ -143,6 +143,7 @@ describe('generateGqlQueryFromTable', () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
"
|
||||
`);
|
||||
expect(variables).toBe(undefined);
|
||||
|
@ -86,10 +86,12 @@ export const generateGqlQueryFromTable = (
|
||||
const fieldName = table.table_name;
|
||||
const fields = table.columns;
|
||||
const pascalCaseName = toPascalCase(fieldName);
|
||||
const tableSchemaPart =
|
||||
table.table_schema !== 'public' ? `${table.table_schema}_` : '';
|
||||
|
||||
if (operationType === 'query') {
|
||||
const query = `query Get${pascalCaseName} {
|
||||
${fieldName} {
|
||||
${tableSchemaPart}${fieldName} {
|
||||
${indentFields(fields, 2)}
|
||||
}
|
||||
}
|
||||
@ -113,8 +115,9 @@ export const generateGqlQueryFromTable = (
|
||||
.map(sf => `${sf.column_name}: $${sf.column_name}`)
|
||||
.join(', ')
|
||||
.trim();
|
||||
|
||||
const query = `mutation Insert${pascalCaseName}(${args}) {
|
||||
insert_${fieldName}(objects: {${argsUsage}}) {
|
||||
insert_${tableSchemaPart}${fieldName}(objects: {${argsUsage}}) {
|
||||
affected_rows
|
||||
returning {
|
||||
${indentFields(fields, 3)}
|
||||
@ -145,7 +148,7 @@ export const generateGqlQueryFromTable = (
|
||||
);
|
||||
|
||||
const query = `subscription Get${pascalCaseName}StreamingSubscription {
|
||||
${fieldName}_stream(batch_size: 10, cursor: {initial_value: {${
|
||||
${tableSchemaPart}${fieldName}_stream(batch_size: 10, cursor: {initial_value: {${
|
||||
initialValueColumn.column_name
|
||||
}: ${initialValue}}}) {
|
||||
${indentFields(fields, 2)}
|
||||
@ -160,11 +163,12 @@ export const generateGqlQueryFromTable = (
|
||||
|
||||
if (operationType === 'subscription') {
|
||||
const query = `subscription Get${pascalCaseName}StreamingSubscription {
|
||||
${fieldName} {
|
||||
${tableSchemaPart}${fieldName} {
|
||||
${indentFields(fields, 2)}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
`;
|
||||
return {
|
||||
query,
|
||||
|
Loading…
Reference in New Issue
Block a user