@ctil/gql 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3768,14 +3768,14 @@ function buildGraphQLQueryList(input) {
3768
3768
  if (limit !== void 0) topArgs.push(`limit: ${limit}`);
3769
3769
  if (offset !== void 0) topArgs.push(`offset: ${offset}`);
3770
3770
  const topArgsStr = topArgs.length ? `(${topArgs.join(" ")})` : "";
3771
- const query2 = `query ${operationName}${varDefs ? `(${varDefs})` : ""} { ${operationName}${topArgsStr} ${fields ? "{" + buildFields(fields) + "}" : ""} }`;
3771
+ const query2 = `query ${operationName.toLowerCase()}${varDefs ? `(${varDefs})` : ""} { ${operationName.toLowerCase()}${topArgsStr} ${fields ? "{" + buildFields(fields) + "}" : ""} }`;
3772
3772
  return { query: query2, variables };
3773
3773
  }
3774
3774
  function buildGraphQLQueryByIdFixed(queryByIdInput) {
3775
3775
  const { pk, fields, operationName } = queryByIdInput;
3776
3776
  const variables = { id: pk };
3777
- const query2 = `query ${operationName + "_by_pk"}($id: Long!) {
3778
- ${operationName + "_by_pk"}(id: $id) {
3777
+ const query2 = `query ${operationName.toLowerCase() + "_by_pk"}($id: Long!) {
3778
+ ${operationName.toLowerCase() + "_by_pk"}(id: $id) {
3779
3779
  ${buildFields(fields)}
3780
3780
  }
3781
3781
  }`;
@@ -3794,7 +3794,7 @@ function buildGraphQLQueryPageList(input) {
3794
3794
  if (size !== void 0) topArgs.push(`size: ${size}`);
3795
3795
  if (page !== void 0) topArgs.push(`page: ${page}`);
3796
3796
  const topArgsStr = topArgs.length ? `(${topArgs.join(" ")})` : "";
3797
- const query2 = `query ${"get" + toPascalCase(operationName) + "PageList"}${varDefs ? `(${varDefs})` : ""} { ${"get" + toPascalCase(operationName) + "PageList"}${topArgsStr} { hasMore list{${buildFields(fields)}} page size total } }`;
3797
+ const query2 = `query ${"get" + operationName + "PageList"}${varDefs ? `(${varDefs})` : ""} { ${"get" + toPascalCase(operationName) + "PageList"}${topArgsStr} { hasMore list{${buildFields(fields)}} page size total } }`;
3798
3798
  return { query: query2, variables };
3799
3799
  }
3800
3800
  function buildGraphQLQueryAggregate(input) {
@@ -3818,8 +3818,8 @@ function buildGraphQLQueryAggregate(input) {
3818
3818
  }
3819
3819
  const aggregateStr = aggregateParts.join(" ");
3820
3820
  const query2 = `
3821
- query ${operationName + "_aggregateount"}${varDefs ? `(${varDefs})` : ""} {
3822
- ${operationName}_aggregateount${topArgsStr} {
3821
+ query ${operationName.toLowerCase() + "_aggregateount"}${varDefs ? `(${varDefs})` : ""} {
3822
+ ${operationName.toLowerCase() + "_aggregateount"}${topArgsStr} {
3823
3823
  aggregate { ${aggregateStr} }
3824
3824
  nodes { ${buildFields(fields)} }
3825
3825
  }
@@ -3831,7 +3831,7 @@ function buildGraphQLQueryAggregate(input) {
3831
3831
  // src/builders/mutation.ts
3832
3832
  function buildGraphQLMutationInsertOne(input) {
3833
3833
  const { operationName, fields, data, variables } = input;
3834
- const entityName = operationName.toLowerCase();
3834
+ const entityName = operationName;
3835
3835
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3836
3836
  let dataArg;
3837
3837
  if (variables && variables.data) {
@@ -3843,7 +3843,7 @@ function buildGraphQLMutationInsertOne(input) {
3843
3843
  if (!variables || !variables.data) {
3844
3844
  finalVariables.data = data;
3845
3845
  }
3846
- const mutationName = `insert_${entityName}_one`;
3846
+ const mutationName = `insert_${entityName.toLowerCase()}_one`;
3847
3847
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3848
3848
  ${mutationName}(${operationName}: ${dataArg}) {
3849
3849
  ${buildMutationFields(fields)}
@@ -3853,7 +3853,7 @@ function buildGraphQLMutationInsertOne(input) {
3853
3853
  }
3854
3854
  function buildGraphQLMutationBatchInsert(input) {
3855
3855
  const { operationName, fields, datas, variables } = input;
3856
- const entityName = operationName.toLowerCase();
3856
+ const entityName = operationName;
3857
3857
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3858
3858
  let datasArg;
3859
3859
  if (variables && variables.datas) {
@@ -3866,7 +3866,7 @@ function buildGraphQLMutationBatchInsert(input) {
3866
3866
  if (!variables || !variables.datas) {
3867
3867
  finalVariables.datas = datas;
3868
3868
  }
3869
- const mutationName = `insert_${entityName}s`;
3869
+ const mutationName = `insert_${entityName.toLowerCase()}s`;
3870
3870
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3871
3871
  ${mutationName}(${operationName}s: ${datasArg}) {
3872
3872
  affected_rows
@@ -3877,7 +3877,7 @@ function buildGraphQLMutationBatchInsert(input) {
3877
3877
  }
3878
3878
  function buildGraphQLMutationUpdate(input) {
3879
3879
  const { operationName, fields, _set, where, variables } = input;
3880
- const entityName = operationName.toLowerCase();
3880
+ const entityName = operationName;
3881
3881
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3882
3882
  const args = [];
3883
3883
  let setArg;
@@ -3892,7 +3892,7 @@ function buildGraphQLMutationUpdate(input) {
3892
3892
  if (!variables || !variables._set) {
3893
3893
  finalVariables._set = _set;
3894
3894
  }
3895
- const mutationName = `update_${entityName}`;
3895
+ const mutationName = `update_${entityName.toLowerCase()}`;
3896
3896
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3897
3897
  ${mutationName}(${args.join(", ")}) {
3898
3898
  ${buildMutationFields(fields)}
@@ -3902,7 +3902,7 @@ function buildGraphQLMutationUpdate(input) {
3902
3902
  }
3903
3903
  function buildGraphQLMutationBatchUpdate(input) {
3904
3904
  const { operationName, fields, _set, variables } = input;
3905
- const entityName = operationName.toLowerCase();
3905
+ const entityName = operationName;
3906
3906
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3907
3907
  let setArg;
3908
3908
  if (variables && variables._set) {
@@ -3915,7 +3915,7 @@ function buildGraphQLMutationBatchUpdate(input) {
3915
3915
  if (!variables || !variables._set) {
3916
3916
  finalVariables._set = _set;
3917
3917
  }
3918
- const mutationName = `update_${entityName}_many`;
3918
+ const mutationName = `update_${entityName.toLowerCase()}_many`;
3919
3919
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3920
3920
  ${mutationName}(_set: ${setArg}) {
3921
3921
  affected_rows
@@ -3926,7 +3926,7 @@ function buildGraphQLMutationBatchUpdate(input) {
3926
3926
  }
3927
3927
  function buildGraphQLMutationUpdateByPk(input) {
3928
3928
  const { operationName, fields, _set, pk_columns, variables } = input;
3929
- const entityName = operationName.toLowerCase();
3929
+ const entityName = operationName;
3930
3930
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3931
3931
  const args = [];
3932
3932
  let setArg;
@@ -3941,7 +3941,7 @@ function buildGraphQLMutationUpdateByPk(input) {
3941
3941
  if (!variables || !variables._set) {
3942
3942
  finalVariables._set = _set;
3943
3943
  }
3944
- const mutationName = `update_${entityName}_by_pk`;
3944
+ const mutationName = `update_${entityName.toLowerCase()}_by_pk`;
3945
3945
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3946
3946
  ${mutationName}(${args.join(", ")}) {
3947
3947
  ${buildMutationFields(fields)}
@@ -3951,10 +3951,10 @@ function buildGraphQLMutationUpdateByPk(input) {
3951
3951
  }
3952
3952
  function buildGraphQLMutationDeleteById(input) {
3953
3953
  const { operationName, fields, pk_columns, variables } = input;
3954
- const entityName = operationName.toLowerCase();
3954
+ const entityName = operationName;
3955
3955
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3956
3956
  const args = `pk_columns: ${formatGraphQLValue(pk_columns)}`;
3957
- const mutationName = `delete_${entityName}_by_pk`;
3957
+ const mutationName = `delete_${entityName.toLowerCase()}_by_pk`;
3958
3958
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3959
3959
  ${mutationName}(${args}) {
3960
3960
  ${buildMutationFields(fields)}
@@ -3964,10 +3964,10 @@ function buildGraphQLMutationDeleteById(input) {
3964
3964
  }
3965
3965
  function buildGraphQLMutationDelete(input) {
3966
3966
  const { operationName, fields, where, variables } = input;
3967
- const entityName = operationName.toLowerCase();
3967
+ const entityName = operationName;
3968
3968
  const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
3969
3969
  const args = `where: { ${buildWhere(where)} }`;
3970
- const mutationName = `delete_${entityName}`;
3970
+ const mutationName = `delete_${entityName.toLowerCase()}`;
3971
3971
  const query2 = `mutation ${mutationName}${varDefs ? `(${varDefs})` : ""} {
3972
3972
  ${mutationName}(${args}) {
3973
3973
  affected_rows
@@ -4547,6 +4547,7 @@ var clearHeaders = () => getClient().clearHeaders();
4547
4547
  var query = {
4548
4548
  async list(input, useCache = true, ttl) {
4549
4549
  return rateLimit("list", "query", async () => {
4550
+ input.operationName = input.operationName + "s";
4550
4551
  const { query: q, variables } = buildGraphQLQueryList(input);
4551
4552
  const key = getCacheKey(q, variables);
4552
4553
  if (useCache) {