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

@createMany

Create many new Lucid models with the given arguments.

Required argument when writing a mutation:

  • input - type Input (array)

For a separate add use

/* ... */
const {
  CreateManyDirective,
  CreateManyTypeDefs
} = require('apollo-server-adonis-directives-pack/src/directives/mutation/CreateMany')

makeExecutableSchema({ 
  /* ... */ 
  typeDefs: [ CreateManyTypeDefs, /* ... */ ],
  schemaDirectives: { CreateManyDirective, /* ... */} 
})

Definition

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

Use the @createMany directive only to create many new models

Example

input CreatePostInput {
    name: String!
    text: String
}

type Mutation {
    createManyPost(input: [CreatePostInput!]!): [Post] @createMany
}
Previous@createNext@update

Last updated 4 years ago

Was this helpful?