@@ -29,6 +29,16 @@ module ComplexMutation = %relay(`
2929 }
3030` )
3131
32+ module MutationWithProvidedVariableFragment = %relay (`
33+ mutation TestMutationWithProvidedVariableFragmentMutation {
34+ updateUserAvatar {
35+ user {
36+ ...TestMutationProvidedVariable_user
37+ }
38+ }
39+ }
40+ ` )
41+
3242module MutationWithOnlyFragment = %relay (`
3343 mutation TestMutationWithOnlyFragmentSetOnlineStatusMutation($onlineStatus: OnlineStatus!) @raw_response_type {
3444 setOnlineStatus(onlineStatus: $onlineStatus) {
@@ -57,6 +67,15 @@ module Fragment = %relay(`
5767 }
5868` )
5969
70+ module ProvidedVariableFragment = %relay (`
71+ fragment TestMutationProvidedVariable_user on User
72+ @argumentDefinitions(
73+ bool: { type: "Boolean!", provider: "ProvidedVariables.Bool" }
74+ ) {
75+ someRandomArgField(bool: $bool)
76+ }
77+ ` )
78+
6079module MutationWithInlineFragment = %relay (`
6180 mutation TestMutationWithInlineFragmentSetOnlineStatusMutation($onlineStatus: OnlineStatus!) @raw_response_type {
6281 setOnlineStatus(onlineStatus: $onlineStatus) {
@@ -84,6 +103,9 @@ module Test = {
84103 let data = Fragment .use (query .loggedInUser .fragmentRefs )
85104 let (mutate , isMutating ) = Mutation .use ()
86105 let (inlineStatus , setInlineStatus ) = React .useState (_ => "-" )
106+ let (providedVariableMutationStatus , setProvidedVariableMutationStatus ) = React .useState (_ =>
107+ "-"
108+ )
87109 let someJsonValue =
88110 [
89111 ("foo" , JSON .Encode .null ),
@@ -114,6 +136,11 @@ module Test = {
114136 }),
115137 )}
116138 <div > {React .string ("Inline status: " ++ inlineStatus )} </div >
139+ <div >
140+ {React .string (
141+ "Provided variable mutation status: " ++ providedVariableMutationStatus ,
142+ )}
143+ </div >
117144 <button
118145 onClick = {_ => {
119146 let _ = {
@@ -215,6 +242,20 @@ module Test = {
215242 >
216243 {React .string ("Change online status, complex" )}
217244 </button >
245+ <button
246+ onClick = {_ => {
247+ open MutationWithProvidedVariableFragment
248+ commitMutation (~environment , ~variables = (), ~onCompleted = (response , _ ) => {
249+ switch response {
250+ | {updateUserAvatar : Some ({user : Some (_ )})} =>
251+ setProvidedVariableMutationStatus (_ => "completed" )
252+ | _ => setProvidedVariableMutationStatus (_ => "missing user" )
253+ }
254+ })-> RescriptRelay .Disposable .ignore
255+ }}
256+ >
257+ {React .string ("Run mutation with provided variable fragment" )}
258+ </button >
218259 <button
219260 onClick = {_ => {
220261 let _ = {
0 commit comments