are now replaced with a meta tag indicating to a parent that uses quarry Object :mission do field :id, :id field :title, :string field :description, :string field :priority, non_null ( :integer ) field :director, non_null ( :director ), meta : field :agents, list_of ( :agent ), meta : do arg :filter, :agent_filter end endĪll instances of resolve: dataloader(. I can also add sort and limit arguments to the field as needed. Everything is handled by the quarry helper. I’ve also completely deleted theĮ and removed all the boilerplate functions from Espionage.Missions modules I’ve added some additional input objects, and more can easily be added as needed. input_object :mission_filter do field :title, :string field :agents, :agent_filter field :director, :director_filter field :priority_gte, :integer end input_object :agent_filter do field :name, :string field :base, :base_filter end input_object :director_filter do field :name, :string field :base, :base_filter end input_object :base_filter do field :name, :string end. To fetch the title off of the %Mission query do field :missions, list_of ( :mission ) do arg :filter, :mission_filter resolve quarry ( Mission, Repo ) end end. mission / 3 end object :base do field :id, :id field :name, :string end endįields like title on a mission object don’t need a resolver function since it can just use the default Map.get base / 3 field :mission, :mission, resolve : & Resolvers.Agent. missions / 3 ) end object :agent do field :id, :id field :name, :string field :base, non_null ( :base ), resolve : & Resolvers.Agent. base / 3 field ( :missions, list_of ( :mission ), resolve : & Resolvers.Director. agents / 3 end object :director do field :id, :id field :name, :string field :base, non_null ( :base ), resolve : & Resolvers.Director. director / 3 field :agents, list_of ( :agent ), resolve : & Resolvers.Mission. missions / 2 ) end end object :mission do field :id, :id field :title, :string field :priority, non_null ( :integer ) field :director, non_null ( :director ), resolve : & Resolvers.Mission. # lib/espionage_api/schema.ex defmodule EspionageApi.Schema do use Absinthe.Schema query do field :missions, list_of ( :mission ) do resolve ( & Resolvers.Mission. I install the Absintheĭependencies, configure the router, then start defining my schema file. In Absinthe, the entire schema is defined up front,Īnd every field needs to have a resolver function that describes how to get the value for that field.įields without an explicit resolver will just use a Map.get(parent, field_name). I open the documentation for Absinthe, the Elixir implementation of the GraphQL spec. But the implementation is another matter. I must say, this seems like the perfect use case for GraphQL, since it promises to allow clients toįetch exactly what they need in one GraphQL request. My eyes squint as I’m blinded by the sudden white background of the GitHub 404 page. This issue will self-destruct in 5 seconds. If you should fail, your existence will be denied by the IMF and all ties to your consultancy Your mission, should you choose to accept it-build a flexible API for the internal “Espionage” App so thatĪgents can use applications that efficiently fetch only the data they need and nothing more. Mission 001: Build a flexible API for “Espionage” ![]() Please consider contributing code and beta testing to the quarry package, and Eric may have a chance to escape. In an attempt to escape, Eric began to develop the Hex package quarry to dig his way to freedom. The following account was found hidden in the end credits of the new “Mission Impossible 7”, detailingĮric Newbury’s journey iterating on a GraphQL API for the Mission Impossible super-spy organization “IMF.”Īs the requirements became more and more complex, Eric found himself a captive of the IMF who monopolize all of his development time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |