All Projects → graphql-community → graphql-directive-computed-property

graphql-community / graphql-directive-computed-property

Licence: MIT license
GraphQL directive for create computed property

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to graphql-directive-computed-property

graphql-directive-rest
GraphQL directive for easy integration with REST API
Stars: ✭ 39 (+21.88%)
Mutual labels:  directive, graphql-directive
babel-plugin-react-directives
A babel plugin that provides some directives for react(JSX), similar to directives of vue.
Stars: ✭ 80 (+150%)
Mutual labels:  directive
remark-directive
remark plugin to support directives
Stars: ✭ 137 (+328.13%)
Mutual labels:  directive
svg-pan-zoom-container
A vanilla-js module for adding zoom-on-wheel and pan-on-drag behavior to inline SVG elements.
Stars: ✭ 31 (-3.12%)
Mutual labels:  directive
ngx-access
Add access control to your components using hierarchical configuration with logical expressions.
Stars: ✭ 21 (-34.37%)
Mutual labels:  directive
ngx-localstorage
An Angular wrapper for localstorage/sessionstorage access.
Stars: ✭ 27 (-15.62%)
Mutual labels:  directive
Vue Scroll
Scroll directive on vue
Stars: ✭ 238 (+643.75%)
Mutual labels:  directive
graphql-custom-directives
A collection of custom graphql directives
Stars: ✭ 108 (+237.5%)
Mutual labels:  graphql-directive
angular-downloader
Angular Downloader is an angularjs directive that enables you to manage browser download - https://720kb.github.io/angular-downloader
Stars: ✭ 16 (-50%)
Mutual labels:  directive
graphql-custom-directive
A custom directive for GraphQL which hooks the query or schema execution
Stars: ✭ 51 (+59.38%)
Mutual labels:  graphql-directive
angular-ellipsis
A simple lightweight library for Angular which removes excess text and add ellipsis symbol to end of text before text overflows container
Stars: ✭ 16 (-50%)
Mutual labels:  directive
ngx-timeago
⏰ Live updating timestamps in Angular 6+
Stars: ✭ 70 (+118.75%)
Mutual labels:  directive
angular-simple-slider
An AngularJS directive providing a simple slider functionality
Stars: ✭ 15 (-53.12%)
Mutual labels:  directive
angular-datetime-inputs
📅 Angular directives for datetime inputs
Stars: ✭ 20 (-37.5%)
Mutual labels:  directive
angular-scrollspy
A simple lightweight library for Angular which automatically updates links to indicate the currently active section in the viewport
Stars: ✭ 34 (+6.25%)
Mutual labels:  directive
angular-inviewport
A simple lightweight library for Angular with no other dependencies that detects when an element is within the browser viewport and adds a "sn-viewport-in" or "sn-viewport-out" class to the element
Stars: ✭ 72 (+125%)
Mutual labels:  directive
ngx-malihu-scrollbar
Angular 2+ scrollbar customization using Malihu jQuery Custom Scrollbar plugin
Stars: ✭ 59 (+84.38%)
Mutual labels:  directive
angular-barcode
An angular directive for lindell's JsBarcode
Stars: ✭ 25 (-21.87%)
Mutual labels:  directive
vue-body-scroll-lock
A Vue directive to lock the body scroll without stopping the target element from scrolling.
Stars: ✭ 30 (-6.25%)
Mutual labels:  directive
angular-paypal-checkout
Angular directive for running PayPal's in-context checkout flow
Stars: ✭ 14 (-56.25%)
Mutual labels:  directive

graphql-directive-computed-property

Version downloads PRs Welcome MIT License

Introduction

The directive allows creating a computed property from fields where is defined.

Table of Contents

Installation

yarn add graphql-directive-computed-property

This package requires graphql and graphql-tools as peer dependency

Usage

const { makeExecutableSchema } = require('graphql-tools');
const computedDirective = require('graphql-directive-computed-property');

const typeDefs = `
  type User {
    firstName: String
    lastName: String
    fullName: String @computed(value: "$firstName $lastName")
  }

  type Query {
    me: User
  }
`;

const resolvers = {
  Query: {
    me: () => ({
      firstName: 'John',
      lastName: 'Doe',
    }),
  },
};

module.exports = makeExecutableSchema({
  typeDefs,
  resolvers,
  schemaDirectives: {
    computed: computedDirective,
  },
});

Query:

query {
  me {
    fullName
  }
}

Result:

{
  fullName: 'John Doe'
}

Computed property work well with other directives like @rest:

Example:

admin: String @rest(url: "${URL_TO_API}") @computed(value: "Are you admin? $admin")

Directive Parameters

Directive params:

value: String

The calculated value. It can contain other fields from the type in which it is defined.

Example:

@computed(value: "$firstName $lastName")

@computed(value: "$price $")

Contributing

I would love to see your contribution. ❤️

For local development (and testing), all you have to do is to run yarn and then yarn dev. This will start the Apollo server and you are ready to contribute 🎉

Run yarn test (try --watch flag) for unit tests (we are using Jest)

LICENSE

The MIT License (MIT) 2018 - Luke Czyszczonik - mailto:[email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].