Socket
Book a DemoInstallSign in
Socket

@okam/directus-query

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okam/directus-query

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

latest
Source
npmnpm
Version
1.4.2
Version published
Maintainers
4
Created
Source

directus-query

This library was generated with Nx.

Usage with NextJS AppRouter

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

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:

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

FAQs

Package last updated on 24 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts