question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphQL Library & Support

See original GitHub issue

Description

Integrating a chainable, function based library for interfacing with Arweave’s GraphQL library would be a great feature to have for the project. The following are a proposed implementation for interfacing with GraphQL.

Proposed Implementation

Initializing a GraphQL query

const arweave = Arweave.init({ ... });
const result = await arweave.query({ ...options }); // Initializes a new query

GraphQL options

arweave.query({
  // Default has the full GraphQL object
  output: `{
     cursor
     node {
        ...
     }
  }`,
});

Select by Tag

arweave
  .query()
  .tag({
    name: 'name',
    values: ['values'],
    sort: 'ASC',
  })
  .tag({ ... }); 

Limit and After

arweave
  .query()
  .after('cursor')
  .limit(10);

Sort by block height

arweave
  .query()
  .sort('ASC');

Block range

arweave
  .query()
  .blocks({ min: 0, max: 10 });

Owners

arweave
  .query()
  .owners([...addresses]);

Recipients

arweave
  .query()
  .recipients([...addresses]);

By block ID

arweave
  .query()
  .blockId([...]);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
t8commented, Jan 13, 2021

The utility isn’t necessarily for making writing queries easier per say. Rather, it would a way for developers to query GraphQL with built-in tools. Or, at least, that is why I’m in favor of this proposal.

Additionally, I’m not attracted to hardcoding the gateway. Pulling this data from the current Arweave instance could allow for dynamic gateway switching in the future. Not sure if/what @TheLoneRonin’s plans were for this. I suppose someone could still do all of this manually, but at the very minimum, building the query function and supporting the GraphQL object appeals to me the most.

Regarding documentation: @TheLoneRonin actually published a very well-written and comprehensive docs site for exactly this! You can find it here.

As a workaround to native arweave-js implementation, @johnletey created a super useful library for querying GraphQL by simply providing the query object: https://github.com/johnletey/arGQL

1reaction
CDDeltacommented, Jan 13, 2021

Additionally, I’m not attracted to hardcoding the gateway. Pulling this data from the current Arweave instance could allow for dynamic gateway switching in the future. Not sure if/what @TheLoneRonin’s plans were for this. I suppose someone could still do all of this manually, but at the very minimum, building the query function and supporting the GraphQL object appeals to me the most.

I’m not sure I entirely follow you here. Are you referring to having the result of the GQL query change at runtime depending on the gateway schema? I think a great benefit of GraphQL is that query results changing is checked for and protected against. I guess we just have different project goals 😅

Regarding documentation: @TheLoneRonin actually published a very well-written and comprehensive docs site for exactly this! You can find it here.

I was more referring to documentation directing/instructing devs on setting up a GraphQL code generator. I love having type-safety with my queries and I think more people should use it. The code generator can also be configured to generate a client object which you use to perform all your queries. It’s awesome.

The utility isn’t necessarily for making writing queries easier per say. Rather, it would a way for developers to query GraphQL with built-in tools. Or, at least, that is why I’m in favor of this proposal.

This makes sense. Having it built into the SDK certainly makes things easier to start with. I’m just not sure it would be a scalable approach in the long term for larger projects or a more complex gateway schema.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL Code Libraries, Tools and Services
A JavaScript library for application development using cloud services, which supports GraphQL backend and React components for working with GraphQL data.
Read more >
13 GraphQL Tools and Libraries You Should Know in 2019
Best tools and libraries for GraphQL API development, queries, components, subscriptions and more. Discover Apollo, Prisma, Bit, GraphiQL, ...
Read more >
Subgraph-compatible server libraries - Apollo GraphQL Docs
Language Framework _service @key (single) @key (multi) @key (composite) @requir... AppSync aws‑appsync ✔️ ✔️ ✔️ ✔️ ✔️ C# (.NET) graphql‑dotnet ✔️ ✔️ ❌ ❌ ❌ C#...
Read more >
Open GraphQL API Library - Neo4j
The Neo4j GraphQL Library is a highly flexible, low-code, open source JavaScript library that enables rapid API development for cross-platform and mobile ...
Read more >
5 GraphQL clients for JavaScript and Node.js - LogRocket Blog
graphql -request is a very minimal GraphQL client. The library is isomorphic, meaning it supports both Node.js and browsers. It comes with first- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found