https://github.com/deptno/graphql-toolbox
https://github.com/deptno/graphql-toolbox
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deptno/graphql-toolbox
- Owner: deptno
- Created: 2020-08-10T16:16:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-30T07:02:12.000Z (about 5 years ago)
- Last Synced: 2025-07-10T23:56:34.725Z (3 months ago)
- Language: TypeScript
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# graphql-toolbox
@wip
## install
```shell script
npm install graphql-toolbox
```## api
### createConnection
currently, only `Int` type `Cursor` is supported.(hardcoded)#### code
```graphql
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
```ts
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({
map: d => new A(d), // d => d
after,
first,
data,
totalCount,
})
}
```
### bridge
> todo:### bridgeArgs
> todo:### createEdge
> todo:### createEdges
> todo:### createPageInfo
> todo:## license
MIT