RecifeJs

RecifeJs

  • Docs
  • Blog
  • Github

›Concepts Basics

RecifeJs

  • About
  • Philosophy
  • Contribution

Getting Started

  • Installation
  • Settings

Concepts Basics

  • Controllers
  • Decorators
  • Middlewares
  • Models
  • Plugins
  • Scalars
  • Validators

CLI

  • Introduction
  • Create Structures

Scalars

Creating Scalar

Use the CLI for create a new scalar:

recife scalar Url

or

npx recife-cli scalar Url


The scalar will be created in the src/scalars directory with the name UrlScalar.ts. And it will have the following content:

import { Kind, GraphQLError } from "graphql";
import ScalarType from "recife";

const UrlScalar: ScalarType = {
  name: "url",
  description: "A url scalar",
  parseValue: value => {
    return value;
  },
  serialize: value => {
    return value;
  },
  parseLiteral: ast => {
    if (ast.kind !== Kind.STRING) {
      throw new GraphQLError(`This "${ast}" is not a string`);
    }

    return ast.value;
  }
};

export default UrlScalar;
Last updated on 6/13/2020 by André Lins
← PluginsValidators →
  • Creating Scalar
RecifeJs

Docs

Getting StartedCLIPhilosophy

Community

User ShowcaseProject ChatBlogGitHubStar
Copyright © 2020 RecifeJs