Kaynağa Gözat

+count to give ability get count via graphql when result type isnt array but Int

Ivan Asmer 5 yıl önce
ebeveyn
işleme
eaca2375f3
1 değiştirilmiş dosya ile 3 ekleme ve 6 silme
  1. 3 6
      expand.js

+ 3 - 6
expand.js

@@ -80,12 +80,9 @@ function mmExpandSchema(gqlSchema){
                         type: GraphQLInt,
                         args: {query: {type: GraphQLString}},
                         async resolve(root, args, context, info){
-                            q = JSON.parse(args.query)
-                            q[1] = q[1] || {}
-                            q[1].count = []
-                            console.log(q)
-                            args.query = JSON.stringify(q)
-                            return find.resolve(root, args, context, info)
+                            const Savable = context.models.SlicedSavable || context.models.Savable 
+                            args = JSON.parse(args.query)
+                            return await Savable.m[outputTypeName].count(...args)
                         }
                     }
                     queryFields[`${outputTypeName}Count`] = count