Git Product home page Git Product logo

opus's People

Contributors

dependabot[bot] avatar ejnshtein avatar yeegor avatar zans-laksa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opus's Issues

Automatic array handling

Overview

Currently, when an array-like field is getting created, it is necessary to pass an additional argument to the creation process:

const people = new Query('people', true)
    .addField('friends', true)
    .addField(new Field('parents', true)
        .addField('gender')
        .addField('age')
    );

const result = await client.post(people);

result[0].friends[0];
result[0].parents[0].gender;
result[0].parents[0].age;

Expected behavior

In the ideal world, this is handled completely automatically.

Brief mockup:

  1. Use GraphQL type introspection functionality to generate the schema of TS types locally.
  2. When building the type - either during the field generation process or query fetching, use the generated schema to determine whether the field is an array or not.

Extensibility

Overview

Opus has started as a lightweight GraphQL client for the plugin system. It has proven itself very useful before, when being a part of the ScandiPWA technology.

The main feature that separates this package from the ScandiPWA implementation are typings.
Though, it is not yet clear how to extend the types of these queries. Opus has no idea about the plugin system, and if some query has additional fields coming from the plugins - they will not be respected by Opus typings.

Memoization

Overview

In Opus, queries are built as objects and then serialized into a graphql document.

The serialization process, although is pretty fast already, can be improved with memoization, at least partly.

Requirements

When having a query for e.g. product, one will fetch it several times for different products with different arguments, but the query itself will remain the same. Hence, when re-fetching a query, it will be necessary to:

  1. process the arguments all over again
  2. use the result of previous query serialization for the body itself

Such a change will bring some additional bundle size. It is required to take a weighted decision on whether such an improvement in performance is worth it. The bundle size growth must be minimal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.