This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-15
Channels
- # announcements (5)
- # architecture (17)
- # aws (2)
- # bangalore-clj (1)
- # beginners (157)
- # boot (22)
- # boot-dev (2)
- # cider (64)
- # clara (2)
- # cljs-dev (3)
- # clojure (30)
- # clojure-art (2)
- # clojure-australia (1)
- # clojure-belgium (1)
- # clojure-denver (1)
- # clojure-dusseldorf (1)
- # clojure-europe (8)
- # clojure-finland (2)
- # clojure-italy (9)
- # clojure-nl (21)
- # clojure-spec (261)
- # clojure-switzerland (3)
- # clojure-uk (67)
- # clojurescript (57)
- # clojurewerkz (2)
- # cursive (3)
- # datomic (27)
- # emacs (12)
- # figwheel-main (2)
- # fulcro (48)
- # garden (67)
- # graphql (41)
- # jobs (8)
- # kaocha (8)
- # liberator (2)
- # lumo (1)
- # off-topic (19)
- # parinfer (9)
- # perun (4)
- # re-frame (50)
- # reagent (7)
- # remote-jobs (4)
- # ring-swagger (20)
- # rum (6)
- # shadow-cljs (170)
- # specter (3)
- # tools-deps (19)
- # vim (3)
I'm using lacinia and defining a type, there is a way to define an "OR" type
{:object {:a {:fields {:b {:type (or nil Int)}}}}
because GraphQL is returning me like:
errors": [
{
"message": "Invalid value for a scalar type.",
"locations": [
{
"line": 4,
"column": 3
}
],
"path": [
"b"
],
"extensions": {
"type": "Int",
"value": "\"\""
}
but I want to type "b" be nullable
sometimes b does not have a value
I will mock to a String then... =\
clj -Srepro -Sdeps '{:deps {com.walmartlabs/lacinia {:mvn/version "0.31.0"}}}' -e "(require '[com.walmartlabs.lacinia.schema :as schema]) (schema/compile '{:object {:a {:fields {:b {:type Int}}}}})"
works in my machine
clj -Srepro -Sdeps '{:deps {com.walmartlabs/lacinia {:mvn/version "0.31.0"}}}' -e "(require '[com.walmartlabs.lacinia.schema :as schema]) (schema/compile '{:object {:a {:fields {:b {:type (non-null Int)}}}}})"
too
it worked here both, but the problem was in the query
yeah, empty string or number
I used String type
it worked here both, but the problem was in the query
I don't think gql lets you have a type that is either a number or string
Or, you'd have to explicitly create a union type and then declare that in your schema
Union types are for objects only; to accomplish a "string or a number" you need to define a new scalar. We actually have one due to a mistake slipping out into production, it's not a big deal.
But I think the issue here is why is a numeric field getting an empty string passed up in the request?
More commonly I think you'd define an object that had both a string and a number field, and leave one or the other as null
.
I don't know about gql genrally, but lacinia won't let you have scalars as members of union types. What you could do is create a custom scalar.