Provide a mechanism to prevent queries and mutations being autogenerated for a given type

Fauna relies on your feedback to educate our product development process. To help us prioritize this feature in our product roadmap, please vote for this topic and complete our 2020 GraphQL Roadmap Survey.

Issue description

Fauna’s GraphQL auto-generates collections and their accompanying CRUD mutations and queries from the uploaded schema. While ergonomic in most cases, there are some cases in which users do not want these extra objects and operations to be automatically added.

Proposal

We could provide a @crud directive in order to enable/disable which queries/mutations will be created automatically. If not provided, everything could be set to true by default. For example:

type User @crud(create: false, read: true, update: true, delete: false) {
  firstName: String!
  lastName: String!
}

Workarounds

  1. If you want to lock down specific actions, you can disable writes via ABAC and only allow the GraphQL API to call a UDF instead. You will still see the auto-generated mutations, but they won’t do anything.
  2. Autogenerated mutations or queries could be overridden, leaving their actual implementation undefined.

Example

Import schema:

type Post {
  title: String!
  content: String!
}

type Query {
  # autogenerated findPostByID will be overridden with a side-effect free implementation
  findPostByID(id: ID!): Post @resolver
}

type Mutation {
  # autogenerated deletePost field will be overridden with a side-effect free implementation
  deletePost(id: ID!): Post @resolver
}

If you have implemented your own custom resolvers that you think could help other users with this, please share them as replies to this topic and/or make a gist and link to it from the awesome-faunadb list.