Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@okam/directus-query

Package Overview
Dependencies
Maintainers
0
Versions
8
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).

  • 1.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
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 20 Dec 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc