1.0.18 • Published 2 years ago

@yuetloo/metadata-composer v1.0.18

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

Metadata Composer

A library that merges metadata from subgraphs indexing different networks. The interface of this library is closely similar to the theGraph interface (i.e. input/output) so that if dApps needs metadata from one network, it can simply use theGraph api with minimal changes.

Usage

import { MetadataComposer } from '@clrfund/metadata-composer'

const urls = ['https://api.thegraph.com/subgraphs/name/yuetloo/metadata-rinkeby']
const composer = new MetadataComposer(urls)

const query = '{ metadataEntries{id} }'
const { data, error } = await composer.query(query)
if( data } {
  console.log(data)
  //    {
  //      metadataEntries: [
  //        {
  //          __typename: 'MetadataEntry',
  //          id: 'rinkeby-0x123...456-59'
  //        }
  //      ]
  //    }
  //
}

if( error ) {
  console.log(error)
  //  [
  //    CombinedError {
  //      name: 'CombinedError',
  //      message: '[GraphQL] No value provided for required argument: `id`',
  //      graphQLErrors: [
  //         GraphQLError: No value provided for required argument: `id`
  //        ... stack trace ...
  //      ]
  //      networkError: undefined,
  //      response: Response {
  //         url: 'https://api.thegraph.com/subgraphs/name/...',
  //         status: 200,
  //         statusText: 'OK',
  //         headers: [Headers]
  //         counter: 0
  //      }
  //   }
  // ]
  //
}

Limitations

Currently, this library only merges the results without sorting or refining the paging according to the query request.

Sorting could be adding later to only sort the data if the orderBy fields are returned as part of the results; unlike subgraph queries which can order fields that are not in the query result.

Paging may not be implemented in this library due to performance impact.

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.11

2 years ago

1.0.15

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago