🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

graphql-mutable_type

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-mutable_type

0.2.0
Rubygems
Version published
Maintainers
1
Created
Source

GraphQL::MutableType

Gem Version Build Status Code Climate Coverage Status

GraphQL::MutableType is an extension to GraphQL::ObjectType that adds the ability of having nested mutation queries. It defines as following:

type Fish {
  id: String
  name: String
  Price: Float
  inStock: Int
  mutation: [FishMutation]
}
type FishMutation {
  update: [UpdateFishMutation]
  sell: [SellFishMutation]
}

And can be queried as following:

query {
  fish(id: "1") {
    id
    name
    price
    mutation {
      sell(weight: 100) {
        inStock
      }
    }
  }
}

Proposal

As working with Facebook's practice of GraphQL, we have found that the mutations are all top level children of "mutation". This keeps us using global mutation names look like "SellFish", "UpdateFish". While all the models and services are coded in the OO way, the organization of mutations reminds me of days with out OO: some structs and a large set of functions that operate on the structs.

So we tried to reorganize the mutations under the Object Type itself, whick looks more like the way models we define our models.

This gem provides a DSL that helps define the types with mutations inside.

Usage

Just warp your mutations in mutation do ... end.

KingType = GraphQL::MutableType.define do
  name 'King'
  description 'The title of the ruler of the kingdom'

  field :id,   !types.ID
  field :name, !types.String

  mutation do
    field :rename, field: RenameKingField
  end
end

See alse: test schema

License

This gem is released under the MIT License

FAQs

Package last updated on 04 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts