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

remix-graphql

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remix-graphql

Utilities for using GraphQL with a Remix app

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
157
increased by16.3%
Maintainers
1
Weekly downloads
 
Created
Source

remix-graphql

Remix and GraphQL can live together in harmony ❤️ This package contains basic utility functions that can help you with that.

To be more speciic, here's what the latest version of remix-graphql can help you with:

  • Setting up a GraphQL API as a resource route

And here are some cool ideas what it might do as well in the future:

  • Creating loaders and actions based on GraphQL queries and mutations
  • Executing these operations against a resource route in the same project or against a remote GraphQL API
  • Batching queries from multiple loaders into a single API request

API

The package exports the following functions and types.

createActionFunction

This higher-order-function returns a loader function that can handle GraphQL requests via POST.

// app/routes/graphql.ts
import { createActionFunction } from "remix-graphql";
import schema from "~/graphql/schema.ts";

export const loader = createActionFunction({ schema });

The function accepts a single argument of the following type:

type Options = {
  // The schema to use for execution (required)
  schema: GraphQLSchema;
  // Compute a custom status code for a successfully executed operation (optional)
  deriveStatusCode: DeriveStatusCodeFunction;
};

createLoaderFunction

This higher-order-function returns a loader function that can handle GraphQL requests via GET.

// app/routes/graphql.ts
import { createLoaderFunction } from "remix-graphql";
import schema from "~/graphql/schema.ts";

export const loader = createLoaderFunction({ schema });

The function accepts a single argument of the following type:

type Options = {
  // The schema to use for execution (required)
  schema: GraphQLSchema;
  // Compute a custom status code for a successfully executed operation (optional)
  deriveStatusCode: DeriveStatusCodeFunction;
};

DeriveStatusCodeFunction

This TypeScript type can be used for explicit typing of the deriveStatusCode option that can be passed to createActionFunction and createLoaderFunction.

type DeriveStatusCodeFunction = (
  // This type comes from the "graphql" package
  executionResult: ExecutionResult,
  // This is the status code that would be returned by default
  defaultStatusCode: number
) => number;

Keywords

FAQs

Package last updated on 02 Jan 2022

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