0.5.0 • Published 3 days ago

@daohaus/moloch-v3-data v0.5.0

Weekly downloads
-
License
-
Repository
github
Last release
3 days ago

@daohaus/moloch-v3-data

The moloch-v3-data package was developed to encapsulate our subgraphs, empowering you to perform common queries across diverse entities with ease. The library is designed with optimization at its core, transforming the data you receive into a highly user-friendly and easy-to-manipulate format.

The library's functions let you find single entities or query lists, and the list queries are supplemented with several helper tools for paginating, filtering and sorting.

View on NPM

Usage

Installation

yarn add @daohaus/moloch-v3-data

Requirements

If you are trying to query for data on Etheruem Mainnet or Gnosis Chain (and more to come) you will need to provide an api Key from The Graph. Learn to get those here and here.

Examples

How to find a single entity by ID.

import { findDao } from '@daohaus/moloch-v3-data';

const daoRes = await findDao({
  networkId: '0x1',
  dao: '0x0DaoContractAddress',
  includeTokens: true,
  graphApiKeys: {
    '0x1': 'graphApiKey',
  },
});

How to find a a list of entities.

import { listProposals, Proposal_Filter, Proposal_OrderBy } from '@daohaus/moloch-v3-data';

const list = await listProposals({
  networkId: '0x1',
  filter: {
    createdAt_gte: '1656693140',
  },
  ordering: {
    orderBy: 'createdAt',
    orderDirection: 'asc',
  },
  paging: {
    pageSize: '20',
    offset: '1',
  },
  graphApiKeys: {
    '0x1': 'graphApiKey',
  },
});

Filtering Provide any query the graph supports on fields within the entity you are querying. The Graph docs contain examples on filtering.

Ordering Provide a field to order by and the order direction (asc or desc).

Paging The SDK supports offest and cursor pagination. Cursor pagination overrides the ordering to the ID field. Pagination defaults to returning the first 100 results and provides the query required to get to the next page.

{
  pageSize: '20',
  offset: '0'
}

{
  pageSize: '2000',
  lastId: '0'
}

Building

Run nx run moloch-v3-data:build to build the library.

Generating GraphQL Schema and Types

  1. When updates are deployed to the moloch-v3haus V3 subgraphs, a new schema should be generated

    run nx generate-gql-schema moloch-v3-data to create a new src/subgraph/schema.graphql file

  2. When there is a new schema or new query files are added, new types should be generated

    run nx generate-gql-types moloch-v3-data to create type files for each query file in src/subgraph/queries

0.5.0

3 days ago

0.4.5

4 days ago

0.4.4

1 month ago

0.4.3

2 months ago

0.4.2

3 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.3.3

5 months ago

0.1.32

10 months ago

0.2.0-alpha.0

9 months ago

0.2.0-alpha.4

9 months ago

0.2.0-alpha.3

9 months ago

0.2.0-alpha.6

9 months ago

0.2.0-alpha.5

9 months ago

0.3.0

7 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.3.2

6 months ago

0.2.3

8 months ago

0.3.1

6 months ago

0.2.2

8 months ago

0.1.31

11 months ago

0.1.30

11 months ago

0.1.27

12 months ago

0.1.28

12 months ago

0.1.29

11 months ago

0.1.25

12 months ago

0.1.26

12 months ago

0.1.21

1 year ago

0.1.22

1 year ago

0.1.23

1 year ago

0.1.24

1 year ago

0.1.20

1 year ago

0.1.19

1 year ago

0.1.16

1 year ago

0.1.17

1 year ago

0.1.18

1 year ago

0.1.4

1 year ago

0.1.5

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago