Fork me on GitHub

how do you guys generally test your graphql server?


I have a graphql server which only has Query, and right now all it does is essentially translate graphql query string to sql query string, and run the query with very minimal transformation/computation in between.


i can only think of to populate the test db with some sample data, than run 1~2 query through api and verify it works as expected, but i feel like that's not testing much here.


my resolver function is pretty generic as well, one looks like:

(defn query-entities
  [{:keys [x-user-id db] :as context}
   {:keys [filter orderBy first skip] :as args}
   {:keys [uuid] :as value}]
  (let [constraints (merge filter
                           {:user-id x-user-id}
                           (when uuid
                             {:import-uuid uuid}))
        query-configs (select-keys args [:orderBy :first :skip])]
   (db/query-all-from-table db :entities query-configs)))


I don't think I can manually write all possible query and verify them, but I couldn't come up with a generative test for it either 😞


Finally, please look into using io.aviso/pretty, as sometimes the details are hidden inside the ex-data, and pretty ensures that gets printed out.