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. Query

@find

Request one "Lucid" model by primary key

Required argument when writing a request

  • id - String/Int/ID

Other arguments are ignored.

For a separate add use

/* ... */
const {
  FindDirective,
  FindTypeDefs
} = require('apollo-server-adonis-directives-pack/src/directives/query/Find')


makeExecutableSchema({ 
  /* ... */ 
  typeDefs: [ FindTypeDefs, /* ... */ ],
  schemaDirectives: { FindDirective, /* ... */} 
})

Definition

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

Find directive searches for the primary key of a model

Example

type Query {
    postFind(id: String!): Post @find
}
Previous@allNextMutation

Last updated 4 years ago

Was this helpful?