0.1.6 • Published 4 years ago

graphql-toolbox v0.1.6

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

graphql-toolbox

@wip

install

npm install graphql-toolbox

api

createConnection

currently, only Int type Cursor is supported.(hardcoded)

code

schema {
  query: Query
}
type Query {
  aConnection(after: Cursor! first: Int!): AConnection!
}
type AConnection {
  totalCount: Int!
  pageInfo: PageInfo!
  edges: [A!]!
}
type PageInfo {
  endCursor: Cursor
  endPage: Int!
  itemsOnPage: Int!
  totalCount: Int!
  page: Int!
  hasNextPage: Boolean!
}

scalar A
scalar Cursor # Currently only Int type is supported

code

async function aConnection(parent, args, context) {
    const {after, first} = args
    const {filter} = parent
    const [data, totalCount] = await Promise.all([
      context.dataSources.db.getData({after, first, ...filter}),
      context.dataSources.db.getDataCount(filter),
    ])

    return createConnection<BookmarkConnection>({
      map: d => new A(d), // d => d
      after,
      first,
      data,
      totalCount,
    })
}

bridge

todo:

bridgeArgs

todo:

createEdge

todo:

createEdges

todo:

createPageInfo

todo:

license

MIT

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago