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

bs-graphql-scalar

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bs-graphql-scalar

BuckleScript interface to create GraphQL Custom Scalar types

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bs-graphql-scalar

version downloads license

BuckleScript utilities for creating new GraphQL scalar types.

Getting Started

To create a new scalar using the graphql JavaScript libary, you need three functions:

  • serialize - Used when serializing results to send back to the client.
  • parseValue - Used to parse input that was provided as variables by the client.
  • parseLiteral - Used to parse input that was provided inline in the query.

Example


let serializeDateTime = (value) =>
  value |> Js.Date.getTime |> Js.Float.toString |> Js.Nullable.return;

let parseDateTimeValue = (str) =>
  str |> Js.Date.fromString |> Js.Nullable.return;

let parseDateTimeLiteral = (ast) => {
  open Language;
  let kind = getAstKind(ast);
  if (kind === intKind) {
    ast |> getAstValue |> TextUtils.parseInt_(10) |> Js.Nullable.return
  } else {
    Js.Nullable.null
  }
};

let resolvers = {
  "DateTime":
    makeScalar({
      "name": "DateTime",
      "description": "DateTime custom scalar Type",
      "serialize": serializeDateTime,
      "parseValue": parseDateTimeValue,
      "parseLiteral": parseDateTimeLiteral
    }),
};

License

BSD 2-Clause

Keywords

FAQs

Package last updated on 28 Jan 2018

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