2.0.15 • Published 1 year ago

eth-graph-query v2.0.15

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Simple package for creating query to the GraphQL.


Installation

npm install eth-graph-query
  • Or if you use yarn
yarn add eth-graph-query

Usage

  • The first thing you have to do is to create a query instance
const query = new EthGraphQuery(root);
  • This package has three query options. Simply, you can create a direct string query
result = await query.stringQuery(`query query {
  collection1(first: 10) {
    element1
    element2
  }
}`);
  • More readable, you can create a single json query
const result = await query.query({
  collection: 'collection1',
  params: {
    elements: ['element1', 'element2'],
    first: 10,
  },
});
  • You can create a multiple json queries
const result = await query.multipleQuery([
  {
    collection: 'collection1',
    params: {
      elements: ['element11', 'element12'],
    },
  },
  {
    collection: 'collection2',
    params: {
      elements: ['element21', 'element22'],
    },
  },
]);
  • You can create a complex query
const result = await query.multipleQuery([
  {
    collection: 'collection1',
    params: {
      elements: ['element11', 'element12'],
      where: { element11: 'abc' },
    },
  },
  {
    collection: 'collection2',
    params: {
      elements: [
        'element21',
        {
          collection: 'collection3',
          params: {
            elements: ['element31'],
            where: {
              id: { $in: ['123'] },
              token_: { setId: { $in: ['1', 2, true] } },
              element31: 'element31',
            },
            first: 50,
          },
        },
      ],
      where: {
        element21: '123',
        collection3: { element31: '123' },
      },
      inlineFragments: [
        {
          collection: 'BridgeDepositTransaction',
          params: { elements: ['id', 'l1Token'] },
        },
        {
          collection: 'NameSignalTransaction',
          params: { elements: ['id', 'timestamp'] },
        },
      ],
    },
  },
]);

API

Read the API Docs, you also read my examples


For developer

  • Run example
npm run example example/file-name
  • Run test
npm run test

Reference

2.0.15

1 year ago

2.0.1

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.0.62

2 years ago

1.0.61

2 years ago

1.1.21

2 years ago

1.1.31

2 years ago

1.0.63

2 years ago

2.0.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago