Closed tommi-martin closed 1 year ago
Required default false values are dropped from graphql queries. Breaking directives in graphql.
Steps to repeat:
getPostCollection.graphql
query postCollectionQuery( $list: Boolean = false ) { postCollection { items { content @skip(if: $list) { json } shortDescription @include(if: $list) { json } } } }
(ns sample (:require [graphql-builder.parser :refer [defgraphql]] [graphql-builder.core :as graphql-core]))
(defgraphql graphql-query "getPostCollection.graphql") (def single-query (graphql-core/query-map graphql-query)) (:query (:graphql ((get-in single-query [:query :post-collection-query]))))
**Expected result:**
**Actual result**
query postCollectionQuery(
$list: Boolean ) { postCollection { items { content @skip(if: $list) { json } shortDescription @include(if: $list) { json } } } }
When this query is pushed to contentful for example the result is a 503 as the query validator does not explicitly report this problem back to the graphql client.
@tommi-martin 0.1.15 is released with the fix
Required default false values are dropped from graphql queries. Breaking directives in graphql.
Steps to repeat:
getPostCollection.graphql
(defgraphql graphql-query "getPostCollection.graphql") (def single-query (graphql-core/query-map graphql-query)) (:query (:graphql ((get-in single-query [:query :post-collection-query]))))
query postCollectionQuery( $list: Boolean = false ) { postCollection { items { content @skip(if: $list) { json } shortDescription @include(if: $list) { json } } } }
query postCollectionQuery(
NOTE the missing default value breaking the directives below.
$list: Boolean ) { postCollection { items { content @skip(if: $list) { json } shortDescription @include(if: $list) { json } } } }