Determining What A Resolver UDF Function Returns

I recently answered a stackoverflow question that is very similar: filter by Time in graphql (using faunaDB service) - Stack Overflow

And it’s quite natural that you are confused about the data property. The thing to understand why in one query it’s there and in the other it is not is the following:

  • that data property is typical for a return value that is a page in FaunaDB, both in FaunaDB GraphQL pages (every regular result from generated resolvers is paginated by default) as in FQL pages (when using Pagination())
  • when you write a regular query, FaunaDB interprets the schema and augments it.

This augmentation will actually augment the return types of your regular mutations/queries to Pages. For example, in that stackoverflow post, two queries with the return type [Todo!]! will result in the final schema (which you can see in the GraphQL dashboard):
image
As you can guess, the bottom one had a @resolver tag.

This is where this data property is coming from in the regular queries. Resolver return types do not get transformed. And in your UDF you used paginate so you are returning pages which does have the data property yet your return type does not require one. Selecting a property (such as data) can be done with Select as Luigi explained which essentially removes that property from the result.

1 Like