@anchan828/gen-graphql-order-schema
TypeScript icon, indicating that this package has built-in type declarations

0.7.68 • Public • Published

@anchan828/gen-graphql-order-schema

Description

Generate order schema by directive

Quick Start

import { genOrderTypes } from "@anchan828/gen-graphql-order-schema";
import { buildASTSchema, printSchema } from "graphql";

const schema = `

type Test {
  id: ID
}

type Query {
  tests: [Test] @orderBy
}

`;

printSchema(buildASTSchema(genOrderTypes(schema)));
//=>  enum OrderDirection {
//      ASC
//      DESC
//    }
//
//    type Query {
//      tests(orderBy: [TestOrder]): [Test]
//    }
//
//    type Test {
//      id: ID
//    }
//
//    type TestOrder {
//      sort: TestSort
//      direction: OrderDirection
//    }
//
//    enum TestSort {
//      ID
//    }

Options

TODO

Supoprted Types

For now, supported types are Basic Types (String, Int, Float, Boolean, ID), and Enum

License

MIT.

Readme

Keywords

none

Package Sidebar

Install

npm i @anchan828/gen-graphql-order-schema

Weekly Downloads

0

Version

0.7.68

License

MIT

Unpacked Size

30 kB

Total Files

18

Last publish

Collaborators

  • anchan828