open-index/open-npm huggingface dataset:
npm package: @okam/directus-next
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 2.2.1

# directus-next

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build directus-next` to build the library.

## Running unit tests

Run `nx test directus-next` to execute the unit tests via [Jest](https://jestjs.io).

## Draft

### Installation
In your next folder app/api/ directory:
* Create directory draft/
* Create file draft/route.ts
* In route.ts, import handleDraftRoute,
* Define GET function.

### Example
```
import { handleDraftRoute } from '@okam/directus-next'

// eslint-disable-next-line @typescript-eslint/naming-convention
export async function GET(request: Request) {
   return handleDraftRoute({
     url: request.url,
     getDirectusLanguage: () => 'en-CA' // default language to show
   })
}
```

### Environment
Set the secret in your .env and your directus application (preview_secret field).

.env
```
NEXT_API_DRAFT_SECRET=123
```
npm package: @okam/directus-query
Description: This library was generated with [Nx](https://nx.dev).
Latest version: 2.1.1

# directus-query

This library was generated with [Nx](https://nx.dev).

# Usage with NextJS AppRouter

To create a new client, first create a new file with the following content:

```ts
import { initDirectusQuery } from '@okam/directus-query'

const queryClient = initDirectusQuery('https://example.com/api', {
  credentials: 'include',
  mode: 'cors',
  fetch,ù
  headers: {
    Authorization: `Bearer ${process.env.AUTH_TOKEN}`,
  },
})

export default queryClient
```

Then, you can use the client to query data from Directus:

```ts
const variables = {id: 1}
const data = await queryClient.queryGql(DOCUMENT, variables)
```

## Default Environment Variables
Those environment variables are used in graphqlRequestClient (queryGql, useSuspenseGqlQuery) and graphqlRequestAdmin (useSuspenseGqlQueryAdmin)

### Server/Client
```
NEXT_SERVER_GRAPHQL_URL=http://server.internal/graphql/ # server side only
NEXT_PUBLIC_GRAPHQL_URL=https://server.okam.one/graphql/ # server fallback and client side
NEXT_PUBLIC_API_TOKEN=abcdef
```
### Admin
```
NEXT_GRAPHQL_URL_ADMIN=http://server-admin.okam.one/graphql/ # server side only
# admin request use the same token NEXT_PUBLIC_API_TOKEN
```