Start a new topic

How can I get all of the collection data via GraphQL


I found one amazing topic about Serverless GraphQL API using Kinvey Flex Functions & Kinvey Data Collections here 

My question is how can I get json response with all of the record elements - id, name, age, etc... and how can I get again json with all of the records in the table?

Thanks in advance!

1 Comment

Hi Gavrangel,

In the article the graphql query is returning a string and that is being set as a response to the Flex function. In order to return a JSON, you just need to return JSON in the resolve function. Here is an example of calling Flex dataStore() module which makes a request to a Kinvey collection and returns JSON:

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      posts: {
        type: new GraphQLList(PostType),
        resolve(parent, args, context) {
          return context.modules

const graphql = (context, complete, modules) => {
  const graphqlArguments = {
    source: context.body.graphString,
    contextValue: { context, complete, modules }

    .then(data =>
    .catch(error =>

flex.functions.register("graphql", graphql);


Martin Apostolov

Login or Signup to post a comment