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

adonis-apollo

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adonis-apollo

Apollo GraphQL server for AdonisJs

  • 0.17.0-pre.1677073603
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-85.15%
Maintainers
4
Weekly downloads
 
Created
Source

adonis-apollo

Apollo GraphQL server for AdonisJS 5.

Zakodium logo

Maintained by Zakodium

NPM version build status Test coverage npm download

:warning: This module is unstable and in active development. Use at your own risk.

Prerequisites

This provider requires Adonis v5 and won't work with AdonisJS v4.

Installation

npm i adonis-apollo
node ace configure adonis-apollo

Then add the following to the "metaFiles" array in .adonisrc.json:

{
  "pattern": "app/Schemas/*",
  "reloadServer": true
}

Usage

Bind the apollo server to your AdonisJs application.
In start/routes.ts:

import ApolloServer from '@ioc:Zakodium/Apollo/Server';

ApolloServer.applyMiddleware();

// You can also call `applyMiddleware` inside a route group:
Route.group(() => {
  ApolloServer.applyMiddleware();
}).middleware('someMiddleware');

Troubleshooting

Error: Query root type must be provided

Apollo requires a query root type to be defined in your schema. To fix this error, create a file app/Schemas/SomeSchema.graphql with at least a Query type.

For example:

type Query {
  hello: String!
}
BadRequestError: This operation has been blocked as a potential Cross-Site Request Forgery (CSRF)

This error may happen if you try to access the GraphQL endpoint from a browser. Make sure forceContentNegotiationTo is not unconditionally set to 'application/json' in config/app.ts. You can either disable this option or set it to a function that ignores the GraphQL route.

Configuration

TODO

Landing page

To configure the landing page, use the plugins option in config/apollo.ts:

The default configuration is:

import {
  ApolloServerPluginLandingPageLocalDefault,
  ApolloServerPluginLandingPageProductionDefault,
} from '@apollo/server/plugin/landingPage/default';

const plugins = [
  Env.get('NODE_ENV') === 'production'
    ? ApolloServerPluginLandingPageProductionDefault({
        footer: false,
      })
    : ApolloServerPluginLandingPageLocalDefault({
        footer: false,
      }),
];

See the Apollo Graphql documentation to learn how to customize or disable the landing page.

Scalars

All the resolvers from graphql-scalars are installed automatically.

To enable any of the scalar types documented in graphql-scalars, for example DateTime, just add a scalar line to your schema:

scalar DateTime

Uploads

To enable support for GraphQL uploads:

  • Update the config of the bodyparser in config/bodyparser.ts by adding your GraphQL route (by default: /graphql) to the multipart.processManually array.
  • Add the Upload scalar to your schema: scalar Upload.

License

MIT

Keywords

FAQs

Package last updated on 22 Feb 2023

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