Is it possible to query an entire collection with GraphQL without creating an index or UDF?

I just want to query an entire collection

  1. doesnt’ have to be sorted
  2. doesn’t have to be filtered
  3. no parameters
  4. no authorization
  5. just get first 50 or so objects

do I need to create a UDF or index in order to query?

You do need an Index, but for GraphQL, you can update your schema with an additional Query field, and it will create an index for you.

With FQL you would also use an Index. Fauna provides a built-in Index by using the Documents function.

Add an “all documents” Query to your GraphQL schema using the @index directive. Importing the schema will create an index for you.

For example:

type Query {
  allThings: [Thing]! @index
}

If you provide a Query field with no directives, then Fauna defaults to using the @index functionality. That means that the above example can be shortened to just:

type Query {
  allThings: [Thing]!
}

Note that there is nothing special about the name I gave to the field. Here is an earlier forums discussion about how fauna uses the GraphQL schema to generate Indexes:

And some further discussion in the docs:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.