@thiscover/enhance

1.7.4 • Public • Published

thiscover enhance

This library will enhance your schema from a simple delcaration to feature rich document

const schema = `
    type Task {
      id: ID
      name: String
    }
  `;

const newScheam = enhance({ schema, includeDirectives: false });

console.log(printSchema(newScheam));
type Query {
  allTasks(
    limit: Int
    skip: Int
    orderBy: Task_OrderBy
    where: TaskFilter
  ): [Task]

  aTask(where: TaskFilter): Task
}

type Task {
  id: ID
  name: String
}

enum Task_OrderBy {
  id_DESC
  id_ASC
  name_DESC
  name_ASC
}

input TaskFilter {
  id_is: ID
  id_is_not: ID
  id_like: ID
  id_in: [ID!]
  id_not_in: [ID!]
  name_is: String
  name_is_not: String
  name_like: String
  name_in: [String!]
  name_not_in: [String!]
  and: [TaskFilter!]
  or: [TaskFilter!]
}

Now you can query your server like

  query {
    allTasks (skip: 5, limit: 10, where: { name_like: "Find James Bond"} ) {
      id
      name
    }
  }

or

query {
  aTask (where: {id_is: 1}) {
    name
  }
}

or

  query {
    allTasks (skip: 5, limit: 10, where: {
      or: [{ name_like: "Find James Bond"}, { name_like: "Find 007" }]
      }) {
      id
      name
    }
  }

See it in action here using the IMDB dataset that has a basic schema and has been enhanced

Readme

Keywords

none

Package Sidebar

Install

npm i @thiscover/enhance

Weekly Downloads

2

Version

1.7.4

License

MIT

Unpacked Size

51.4 kB

Total Files

33

Last publish

Collaborators

  • thiscover