@simtlix/simfinity-js 2.0.0 → 2.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +7 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simtlix/simfinity-js",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -1499,7 +1499,7 @@ const buildRootQuery = (name, includedTypes) => {
1499
1499
  rootQueryArgs.fields[type.simpleEntityEndpointName] = {
1500
1500
  type: type.gqltype,
1501
1501
  args: { id: { type: GraphQLID } },
1502
- resolve(parent, args, context) {
1502
+ async resolve(parent, args, context) {
1503
1503
  /* Here we define how to get data from database source
1504
1504
  this will return the type with id passed in argument
1505
1505
  by the user */
@@ -1510,7 +1510,7 @@ const buildRootQuery = (name, includedTypes) => {
1510
1510
  context,
1511
1511
  };
1512
1512
  excecuteMiddleware(params);
1513
- return type.model.findById(args.id);
1513
+ return await type.model.findById(args.id);
1514
1514
  },
1515
1515
  };
1516
1516
 
@@ -1538,9 +1538,9 @@ const buildRootQuery = (name, includedTypes) => {
1538
1538
 
1539
1539
  let result;
1540
1540
  if (aggregateClauses.length === 0) {
1541
- result = type.model.find({});
1541
+ result = await type.model.find({});
1542
1542
  } else {
1543
- result = type.model.aggregate(aggregateClauses);
1543
+ result = await type.model.aggregate(aggregateClauses);
1544
1544
  }
1545
1545
  return result;
1546
1546
  },
@@ -1666,14 +1666,14 @@ const autoGenerateResolvers = (gqltype) => {
1666
1666
  const relatedType = fieldEntry.type instanceof GraphQLNonNull ? fieldEntry.type.ofType : fieldEntry.type;
1667
1667
  const connectionField = relation.connectionField || fieldName;
1668
1668
 
1669
- fieldEntry.resolve = (parent) => {
1669
+ fieldEntry.resolve = async (parent) => {
1670
1670
  // Lazy lookup of the related model
1671
1671
  const relatedTypeInfo = typesDict.types[relatedType.name];
1672
1672
  if (!relatedTypeInfo || !relatedTypeInfo.model) {
1673
1673
  throw new Error(`Related type ${relatedType.name} not found or not connected. Make sure it's connected with simfinity.connect() or simfinity.addNoEndpointType().`);
1674
1674
  }
1675
1675
  const relatedId = parent[connectionField] || parent[fieldName];
1676
- return relatedId ? relatedTypeInfo.model.findById(relatedId) : null;
1676
+ return relatedId ? await relatedTypeInfo.model.findById(relatedId) : null;
1677
1677
  };
1678
1678
  }
1679
1679
  }
@@ -1778,4 +1778,4 @@ function formatArgs(argsArray) {
1778
1778
  graphqlArgs.push(item);
1779
1779
  }
1780
1780
  return graphqlArgs;
1781
- }
1781
+ }