> For the complete documentation index, see [llms.txt](https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/usage.md).

# Usage

## Exported Objects

The package provides an object with directive classes and an array with GraphQL schemes:

SchemaDirective - object with directive classes\
TypeDefsDirective - array with GraphQL schemes

Complete your schema configuration with these objects.\
This is an example of how I do it in my projects:

```javascript
const { makeExecutableSchema } = require('graphql-tools')
const fs = require('fs')
const typeDefs = fs.readFileSync(__dirname + '/types.graphql', { encoding: 'utf8' })
const resolvers = require('./resolvers.js')
const { find, all } = require('./directives')

const { 
  TypeDefsDirective, 
  SchemaDirective 
} = require('apollo-server-adonis-directives-pack')

module.exports = makeExecutableSchema({ 
  typeDefs: [typeDefs, ...TypeDefsDirective],
  resolvers, 
  schemaDirectives: { ...SchemaDirective, find, all } 
})
```

{% hint style="info" %}
The example above shows that the scheme is expanded using the package, and is not the main source
{% endhint %}

You can also destructure SchemaDirective and include directives separately.

Use of separate directives:

```javascript
/* ... */
const { 
  TypeDefsDirective,
  SchemaDirective: { belongsTo } 
} = require('apollo-server-adonis-directives-pack')

makeExecutableSchema({ 
  /* ... */ 
  schemaDirectives: { belongsTo, /* ... */} 
})
```

### Usage in schema

Use directives in the usual way in your circuits:

```graphql
type User {
  id: ID!
  name: String
  posts: [Post] @hasMany
  token: Token @hasOne
}

type Post {
  id: ID!
  user_id: Int
  user: User @belongsTo
}

type Token {
  user_id: Int!
  token: String!
  user: User @belongsTo
}
```

For details on each directive, see the API description.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/usage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
