diff --git a/bot-components/GitHub_queries.ml b/bot-components/GitHub_queries.ml index 7443ff0c..9156fce7 100644 --- a/bot-components/GitHub_queries.ml +++ b/bot-components/GitHub_queries.ml @@ -992,7 +992,7 @@ let get_project_field_values ~bot_info ~organization ~project ~field ~options = let open GitHub_GraphQL.GetProjectFieldValues in makeVariables ~organization ~project ~field ~options () |> serializeVariables |> variablesToJson - |> send_graphql_query ~bot_info ~query + |> send_graphql_query ~bot_info ~query ~ignore_errors:true ~parse:(Fn.compose parse unsafe_fromJson) >>= function | Ok result -> ( diff --git a/bot-components/GraphQL_query.ml b/bot-components/GraphQL_query.ml index 352aa3e9..3b635376 100644 --- a/bot-components/GraphQL_query.ml +++ b/bot-components/GraphQL_query.ml @@ -4,8 +4,8 @@ open Utils type api = GitHub | GitLab of string -let send_graphql_query ~bot_info ?(extra_headers = []) ~api ~query ~parse - variables = +let send_graphql_query ~bot_info ?(extra_headers = []) ?(ignore_errors = false) + ~api ~query ~parse variables = let uri = ( match api with | GitLab gitlab_domain -> @@ -46,17 +46,20 @@ let send_graphql_query ~bot_info ?(extra_headers = []) ~api ~query ~parse let json = Yojson.Basic.from_string body in let open Yojson.Basic.Util in let data = json |> member "data" |> parse in - match member "errors" json with - | `Null -> - Ok data - | errors -> - let errors = - to_list errors - |> List.map ~f:(fun error -> error |> member "message" |> to_string) - in - Error - ( "Server responded to GraphQL request with errors: " - ^ String.concat ~sep:", " errors ) + if ignore_errors then Ok data + else + match member "errors" json with + | `Null -> + Ok data + | errors -> + let errors = + to_list errors + |> List.map ~f:(fun error -> + error |> member "message" |> to_string ) + in + Error + ( "Server responded to GraphQL request with errors: " + ^ String.concat ~sep:", " errors ) with | Failure err -> Error (f "Exception: %s" err) diff --git a/bot-components/GraphQL_query.mli b/bot-components/GraphQL_query.mli index 87029670..3044ca32 100644 --- a/bot-components/GraphQL_query.mli +++ b/bot-components/GraphQL_query.mli @@ -3,6 +3,7 @@ type api = GitHub | GitLab of string val send_graphql_query : bot_info:Bot_info.t -> ?extra_headers:(string * string) list + -> ?ignore_errors:bool -> api:api -> query:string -> parse:(Yojson.Basic.t -> 'a)