GithubHelp home page GithubHelp logo

yunoo / graphql-directive-connection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taylorgoolsby/graphql-directive-connection

0.0 1.0 0.0 630 KB

Generate relay connections by marking fields with a @connection directive.

Home Page: https://www.npmjs.com/package/graphql-directive-connection

License: MIT License

TypeScript 97.40% JavaScript 2.60%

graphql-directive-connection's Introduction

graphql-directive-connection

This package generates relay connections by marking fields with a @connection directive, and then passing your SDL through a transformation function.

Features

  • Create the needed Connection and Edge object types.
  • Reassign the type of marked fields to the Connection type.
  • Remove any @connection directives.
  • Generate the PageInfo object type if it hasn't been defined.
  • Throw errors if the generated Connection and Edge types have a name conflict with types already defined in your SDL.
  • Leave everything else in your SDL untouched.
  • Apply cacheControl directives to Connection and Edge types if exist.

Usage examples

TODO

About cacheControl directives

This plugin will apply cacheControl directive on Connection type, edge and pageInfo fields by default.

In order to completely ignore cache arguments and disable cacheControl directive pass cacheControl: false or cacheControl: { enable: false } argument to transform (default plugin export) function The package will then use the largest maxAge across the connection fields with custom types and apply it to non-scalar fields and types (e.g. connection, edges and pageInfo). Apollo v3 supports inheritMaxAge argument which forces a particular field to inherit the maxAge of its parent field. You can enable this feature by passing cacheControl: { enable: true, apollo: true } to a transform function.

Keep in mind that due to the modified cacheControl heuristics in Apollo v3 this will technically make any queries with Connection types present uncacheable (see https://www.apollographql.com/docs/apollo-server/performance/caching/#why-are-these-the-maxage-defaults). Enabling defaultMaxAge across your GraphQL implementation might partially solve the problem, but only for Apollo v2 and lower versions. Thus, it is recommended to leave cacheControl directives enabled.

graphql-directive-connection's People

Contributors

taylorgoolsby avatar yunoo avatar elob avatar liltoto avatar

Watchers

James Cloos avatar

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.