Subset of Ramda for use in graphql.

Usage no npm install needed!

<script type="module">
  import clientDirectivesRamda from 'https://cdn.skypack.dev/@client-directives/ramda';



Subset of Ramda for use in graphql.

Peer Dependencies



    npm i @client-directives/ramda

Supported functions:

For the most part most ramda functions of the form (a) => (b) => c have been converted to the form @function(value: a) which will then receive (b) the field value returned then call the function. If a function requires multiple parameters for setup tried to choose appropriate naming conventions.

Name Example Usage status
add @add(value: 5)
assoc @assoc(key: "key", value: "value")
assocPath @assocPath(path: ["path","to", "field"], value: "value")
clamp @clamp(value: [1, 10])
concat @concat(value: [2, 3, 4])
contains @contains(value: [2, 3, 4])
countBy @R(countBy: "toUpper")
dec @dec
defaultTo @defaultTo(value: 5) x
difference @difference(value: [2, 3, 4])
dissoc @dissoc(value: "b")
dissocPath @dissocPath(value: ["a", "b", "c"])
divide (i) @divide(value: 5)
drop @drop(value: 2)
dropLast @dropLast(value: 3)
dropRepeats @dropRepeats
empty @empty
endsWith @endsWith(value: "a")
equals @equals(value: { a: "foo" })
F @F
fromPairs @fromPairs
gt @gt(value: 2)
gte @gte(value: 3)
has @has(value: "name")
hasPath @hasPath(value: ["user", "firstName"])
head @head
identical @identical(value: 5)
identity @identity) x
inc @inc
includes @includes(value: 3)
indexBy @indexBy(value: "id")
indexOf @indexOf(value: 3)
init @init
insert @insert(at: 3, value: 'x')
insertAll @insertAll(at: 3, value: [1, 2, 3])
intersection @intersection(value: [1, 3, 4, 5])
intersperce @intersperce(value: 'a')
invert @invert
invertObj @invertObj
isEmpty @isEmpty
isNil @isNil
join @join(value: ' ')
keys @keys
last @last
lastIndexOf @lastIndexOf
length @length
lt @lt(value: 3)
lte @lte(value: 3)
mathMod (ii) @mathMod(value: 5)
max @max(value: 10)
mean @mean
median @median
min @min(value: 5)
modulo @modulo(value: 7)
move @move(from: 2, to: 5)
multiply @multiply(value: 2)
negate @negate
not @not
nth @nth(value: 4)
omit @omit(value: ["a", "foo"])
pair @pair(value: "first")
path @path(value: ["a", "b", "c"])
pathOr @pathOr(or: "foo", ["a", "b", "c"])
pick @pick(value: ["foo", "bar"])
pickAll @pickAll(value: ["foo", "bar"])
prepend @prepend(value: "foo")
product @product
project @project(value: ["first", "last"])
prop @prop(value: "foo")
propOr @propOr(or: "foo", value: "bar")
props @props(value: ["first", "last"])
range @range(value: 5)
remove @remove(start: 1, count: 3)
repeat @repeat(value: "hi")
reverse @reverse
slice @slice(from: 2, to: 5)
split @slice(value: "/")
splitAt @splitAt(value: 3)
splitEvery @splitEvery(value: 3)
startsWith @startsWith(value: "a")
subtract @subtract(value: 2)
sum @sum
symmetricDifference @symmetricDifference(value: [1, 3, 4])
T @T
tail @tail
take @take(value: 2)
takeLast @takeLast(value: 5)
toLower @toLower
toPairs @toPairs
toString @toString
toUpper @toUpper
trim @trim
type @type
union @union(value: [1, 3, 4])
uniq @uniq
update @update(at: 2, value: "foo")
values @values
whereEq @whereEq(value: { foo: "bar" })
without @without(value: [1, 2])
xprod @xprod(value: [1, 3])
zip @zip(value: ["a", "b", "c"])
zipObj @zip(value: ["a", "b", "c" ])
  • ✔ indicates finished with tests
  • x indicates some issue ran into.
  • rest are undecided on api or if neccessary (or TODO).

(i) Ramda divide is (numerator, denominator) => value, this is strictly @divide(value: denominator) (ii) Ramda mathMod is (number, mod) => value, this is @mathMod(modulo)

What about Pipe/Compose?

@client-directives automatically pipe directives left to right. Also directives are applied depth first.


  • Finish implementation for all outlined functions
  • Implement functions that take a callback (map, filter,...) as (fn) => ({ props }) => value => ramdaFn(fn, ...props, value) so they can be initialized.
  • Implement common patterns for functions that take a callback as "extra" functions.
  • Revisit API and signatures for 2nd release after use.