๐ŸŒŠ A GraphQL implementation in Gleam

format

Changed files
+33 -8
src
test
+6 -3
src/swell/executor.gleam
··· 155 155 let root_type = schema.query_type(graphql_schema) 156 156 // Apply variable defaults 157 157 let merged_vars = apply_variable_defaults(variables, ctx.variables, ctx) 158 - let ctx_with_defaults = schema.Context(ctx.data, ctx.arguments, merged_vars) 158 + let ctx_with_defaults = 159 + schema.Context(ctx.data, ctx.arguments, merged_vars) 159 160 execute_selection_set( 160 161 selection_set, 161 162 root_type, ··· 185 186 case schema.get_mutation_type(graphql_schema) { 186 187 option.Some(mutation_type) -> { 187 188 // Apply variable defaults 188 - let merged_vars = apply_variable_defaults(variables, ctx.variables, ctx) 189 + let merged_vars = 190 + apply_variable_defaults(variables, ctx.variables, ctx) 189 191 let ctx_with_defaults = 190 192 schema.Context(ctx.data, ctx.arguments, merged_vars) 191 193 execute_selection_set( ··· 220 222 case schema.get_subscription_type(graphql_schema) { 221 223 option.Some(subscription_type) -> { 222 224 // Apply variable defaults 223 - let merged_vars = apply_variable_defaults(variables, ctx.variables, ctx) 225 + let merged_vars = 226 + apply_variable_defaults(variables, ctx.variables, ctx) 224 227 let ctx_with_defaults = 225 228 schema.Context(ctx.data, ctx.arguments, merged_vars) 226 229 execute_selection_set(
+27 -5
test/parser_test.gleam
··· 746 746 parser.Document([ 747 747 parser.NamedQuery( 748 748 name: "Test", 749 - variables: [parser.Variable("count", "Int", option.Some(parser.IntValue("20")))], 749 + variables: [ 750 + parser.Variable("count", "Int", option.Some(parser.IntValue("20"))), 751 + ], 750 752 selections: parser.SelectionSet([parser.Field("users", None, [], [])]), 751 753 ), 752 754 ]) -> True ··· 766 768 parser.Document([ 767 769 parser.NamedQuery( 768 770 name: "Test", 769 - variables: [parser.Variable("name", "String", option.Some(parser.StringValue("Alice")))], 771 + variables: [ 772 + parser.Variable( 773 + "name", 774 + "String", 775 + option.Some(parser.StringValue("Alice")), 776 + ), 777 + ], 770 778 selections: parser.SelectionSet([parser.Field("users", None, [], [])]), 771 779 ), 772 780 ]) -> True ··· 785 793 parser.Document([ 786 794 parser.NamedQuery( 787 795 name: "Test", 788 - variables: [parser.Variable("active", "Boolean", option.Some(parser.BooleanValue(True)))], 796 + variables: [ 797 + parser.Variable( 798 + "active", 799 + "Boolean", 800 + option.Some(parser.BooleanValue(True)), 801 + ), 802 + ], 789 803 selections: parser.SelectionSet([parser.Field("users", None, [], [])]), 790 804 ), 791 805 ]) -> True ··· 804 818 parser.Document([ 805 819 parser.NamedQuery( 806 820 name: "Test", 807 - variables: [parser.Variable("filter", "String", option.Some(parser.NullValue))], 821 + variables: [ 822 + parser.Variable("filter", "String", option.Some(parser.NullValue)), 823 + ], 808 824 selections: parser.SelectionSet([parser.Field("users", None, [], [])]), 809 825 ), 810 826 ]) -> True ··· 823 839 parser.Document([ 824 840 parser.NamedQuery( 825 841 name: "Test", 826 - variables: [parser.Variable("sort", "SortOrder", option.Some(parser.EnumValue("DESC")))], 842 + variables: [ 843 + parser.Variable( 844 + "sort", 845 + "SortOrder", 846 + option.Some(parser.EnumValue("DESC")), 847 + ), 848 + ], 827 849 selections: parser.SelectionSet([parser.Field("users", None, [], [])]), 828 850 ), 829 851 ]) -> True