Skip to content

Commit c1b96ac

Browse files
committed
Add test for fragment merging on the same type
1 parent 71c93f6 commit c1b96ac

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

test/graphql_builder/core_test.clj

+74
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,77 @@ query User {
501501
query-fn (get-in query-map [:query :user])]
502502
(is (= (str/trim inline-nested-fragment-result)
503503
(get-in (query-fn) [:graphql :query])))))
504+
505+
506+
(def fragment-nesting-on-same-type "
507+
508+
mutation validateOrderPersonalInformation($input: ValidateOrderPersonalInformationInput!) {
509+
validateOrderPersonalInformation(input: $input) {
510+
...validateOrderPersonalInformationPayloadFields
511+
}
512+
}
513+
514+
fragment validateOrderPersonalInformationPayloadFields on ValidateOrderPersonalInformationPayload {
515+
clientMutationId
516+
errors {
517+
...errorFields
518+
}
519+
valid
520+
}
521+
522+
fragment errorFields on Error {
523+
...innerErrorFields
524+
suberrors {
525+
...innerErrorFields
526+
suberrors {
527+
...innerErrorFields
528+
suberrors {
529+
...innerErrorFields
530+
}
531+
}
532+
}
533+
}
534+
535+
fragment innerErrorFields on Error {
536+
index
537+
key
538+
messages
539+
}
540+
")
541+
542+
(def fragment-nesting-on-same-type-result
543+
"
544+
mutation validateOrderPersonalInformation($input: ValidateOrderPersonalInformationInput!) {
545+
validateOrderPersonalInformation(input: $input) {
546+
clientMutationId
547+
errors {
548+
index
549+
key
550+
messages
551+
suberrors {
552+
index
553+
key
554+
messages
555+
suberrors {
556+
index
557+
key
558+
messages
559+
suberrors {
560+
index
561+
key
562+
messages
563+
}
564+
}
565+
}
566+
}
567+
valid
568+
}
569+
}
570+
")
571+
572+
573+
(deftest fragment-nesting-on-same-type-test
574+
(let [query-map (core/query-map (parse fragment-nesting-on-same-type) {:inline-fragments true})
575+
query-fn (get-in query-map [:mutation :validate-order-personal-information])]
576+
(is (= (str/trim fragment-nesting-on-same-type-result)
577+
(get-in (query-fn) [:graphql :query])))))

0 commit comments

Comments
 (0)