Skip to content

Commit

Permalink
chore: sync gqlPrettify and update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Selnapenek committed Jun 21, 2022
1 parent b9ba3e6 commit 32c5cfd
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 68 deletions.
13 changes: 10 additions & 3 deletions packages/core/utils/src/queryGenerators/createQueryString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ export const createQueryString = (
isNotEmptyRelation = !R.isEmpty(innerFields);

fieldContent = `{
id
${innerFields}
id${innerFields}
_description
}`;
}
Expand Down Expand Up @@ -162,7 +161,15 @@ export const createQueryString = (
if (!!relationItemsCount && isList && isRelation) {
queryObject += `\n${field.name}(first: ${relationItemsCount}) ${fieldContent}`;
} else {
queryObject += `\n${field.name} ${fieldContent}`;
if (field.name === fieldContent) {
// skip double id
if (field.name !== 'id') {
queryObject += `\n${field.name}`;
}
} else {
queryObject += `\n${field.name}
${fieldContent}`;
}
}
}
});
Expand Down
15 changes: 5 additions & 10 deletions packages/core/utils/src/queryGenerators/queryGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export const createTableFilterGraphqlTag = (
skip: $skip
) {
items {
id
${withResultData ? createQueryString(tablesList, table.id, { ...restConfig }) : ''}
id${withResultData ? createQueryString(tablesList, table.id, { ...restConfig }) : ''}
_description
}
count
Expand All @@ -98,8 +97,7 @@ export const createTableRowCreateTag = (
mutation ${upperFirst(table.name)}Create($data: ${SchemaNameGenerator.getCreateInputName(table.name, appName)}!) {
${wrapInAppName(appName)(`
${SchemaNameGenerator.getCreateItemFieldName(table.name)}(data: $data) {
id
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
id${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
_description
}`)}
}`);
Expand All @@ -109,8 +107,7 @@ export const createTableRowCreateTag = (
mutation ${upperFirst(table.name)}Create {
${wrapInAppName(appName)(`
${SchemaNameGenerator.getCreateItemFieldName(table.name)} {
id
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
id${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
_description
}`)}
}`);
Expand Down Expand Up @@ -160,8 +157,7 @@ export const createTableRowUpdateTag = (
) {
${wrapInAppName(appName)(`
${SchemaNameGenerator.getUpdateItemFieldName(table.name)}(data: $data, filter: $filter) {
id
${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
id${withResultData ? createQueryString(tablesList, tableId, { withMeta: false, ...restConfig }) : ''}
_description
}`)}
}`);
Expand All @@ -180,8 +176,7 @@ export const createTableRowQueryTag = (
query ${upperFirst(table.name)}Entity($id: ID!) {
${wrapInAppName(appName)(`
${SchemaNameGenerator.getTableItemFieldName(table.name)}(id: $id) {
id
${withResultData ? createQueryString(tablesList, tableId, { ...restConfig }) : ''}
id${withResultData ? createQueryString(tablesList, tableId, { ...restConfig }) : ''}
_description
}`)}
}`);
Expand Down
Loading

0 comments on commit 32c5cfd

Please sign in to comment.