@@ -1804,3 +1804,70 @@ function g.test_skip_include_directives()
1804
1804
t .assert_equals (errors , nil )
1805
1805
t .assert_items_equals (data , {test = {uri = " uri1" , uris = {uri = " uri2" }}})
1806
1806
end
1807
+
1808
+ -- test simultaneous usage of mutation and directive default values
1809
+ function g .test_mutation_and_directive_arguments_default_values ()
1810
+ local function callback (_ , _ )
1811
+ return nil
1812
+ end
1813
+
1814
+ local mutation_schema = {
1815
+ [' test_mutation' ] = {
1816
+ kind = types .string .nonNull ,
1817
+ arguments = {
1818
+ object_arg = {
1819
+ kind = types .inputObject ({
1820
+ name = ' test_input_object' ,
1821
+ fields = {
1822
+ nested = {
1823
+ kind = types .string ,
1824
+ defaultValue = ' default Value' ,
1825
+ },
1826
+ },
1827
+ kind = types .string ,
1828
+ }),
1829
+ },
1830
+ mutation_arg = {
1831
+ kind = types .int ,
1832
+ defaultValue = 1 ,
1833
+ },
1834
+
1835
+ },
1836
+ resolve = callback ,
1837
+ }
1838
+ }
1839
+
1840
+ local directives = {
1841
+ types .directive ({
1842
+ schema = schema ,
1843
+ name = ' timeout' ,
1844
+ description = ' Request execute timeout' ,
1845
+ arguments = {
1846
+ seconds = {
1847
+ kind = types .int ,
1848
+ description = ' Request timeout (in seconds). Default: 1 second' ,
1849
+ defaultValue = 1 ,
1850
+ },
1851
+ },
1852
+ onField = true ,
1853
+ })
1854
+ }
1855
+
1856
+ local root = {
1857
+ query = types .object ({
1858
+ name = ' Query' ,
1859
+ fields = {},
1860
+ }),
1861
+ mutation = types .object ({
1862
+ name = ' Mutation' ,
1863
+ fields = mutation_schema or {},
1864
+ }),
1865
+ directives = directives ,
1866
+ }
1867
+
1868
+ local compiled_schema = schema .create (root , test_schema_name )
1869
+
1870
+ -- test that schema.typeMap is not corrupted when both mutation and
1871
+ -- directive default values used on the same argument type
1872
+ t .assert_equals (compiled_schema .typeMap [' Int' ].defaultValue , nil )
1873
+ end
0 commit comments