No commit activity in last 3 years
No release in over 3 years
An Object Type that may have mutation queries.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.13.0
 Project Readme

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