Apollo-server-adonis-directive-pack
  • Introduction
  • Usage
  • API
    • Query
      • @all
      • @find
    • Mutation
      • @create
      • @createMany
      • @update
      • @delete
    • Relationship
      • @hasOne
      • @hasMany
      • @belongsTo
Powered by GitBook
On this page
  • For a separate add use
  • Definition
  • Example

Was this helpful?

  1. API
  2. Mutation

@delete

Delete one or more Lucid models

Required arguments for writing a mutation:

  • id - Int! / [Int!]! / String! / [String!]! / ID! / [ID!]!

For a separate add use

/* ... */
const {
  DeleteDirective,
  DeleteTypeDefs
} = require('apollo-server-adonis-directives-pack/src/directives/mutation/Delete')

makeExecutableSchema({ 
  /* ... */ 
  typeDefs: [ DeleteTypeDefs, /* ... */ ],
  schemaDirectives: { DeleteDirective, /* ... */} 
})

Definition

DeleteTypeDefs
directive @delete(
  # By default, the model will be calculated from the name
  # of the returned "type" with the prefix 'App/Model/'
  model: String) on FIELD_DEFINITION

If you assign a different set to the input and output, this will throw an exception

Delete directive deletes by primary key of model

Example

type Mutation {
    deletePost(id: String!): Post @delete
    deleteManyPost(id: [String!]!): [Post] @delete
}
Previous@updateNextRelationship

Last updated 4 years ago

Was this helpful?

Carefully describe the mutation!

Error: Different sets are installed for input and output.

🤔
❗