{"id":19851144,"url":"https://github.com/maxneuvians/maple","last_synced_at":"2025-05-01T23:30:56.238Z","repository":{"id":57520682,"uuid":"105289015","full_name":"maxneuvians/maple","owner":"maxneuvians","description":"Elixir GraphQL Client | Compile time client code generator for GraphQL APIs based on introspection queries and schema files","archived":false,"fork":false,"pushed_at":"2019-01-14T16:11:40.000Z","size":60,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T19:01:04.301Z","etag":null,"topics":["code-generation","elixir","graphql"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxneuvians.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T15:36:13.000Z","updated_at":"2023-12-14T20:12:50.000Z","dependencies_parsed_at":"2022-09-26T18:01:02.104Z","dependency_job_id":null,"html_url":"https://github.com/maxneuvians/maple","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fmaple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fmaple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fmaple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxneuvians%2Fmaple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxneuvians","download_url":"https://codeload.github.com/maxneuvians/maple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224281498,"owners_count":17285675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","elixir","graphql"],"created_at":"2024-11-12T13:29:04.283Z","updated_at":"2024-11-12T13:29:04.963Z","avatar_url":"https://github.com/maxneuvians.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Maple\n\n[![Master](https://travis-ci.org/maxneuvians/maple.svg?branch=master)](https://travis-ci.org/maxneuvians/maple)\n\nWARNING: This release is just for posterity. There is a major rewrite coming.\n\nMaple is an automatic, compile time, client code generator for GraphQL schemas. At best it creates easy to use\nAPI functions for use in your code. At worst it can be used as a CLI for a GraphQL API.\n\nBest illustrated by an example - given the following code\n\n```elixir\ndefmodule Maple.Examples.Github.Config do\n  Application.put_env(:maple, :api_url, \"https://api.github.com/graphql\")\n  Application.put_env(:maple, :additional_headers, %{\"Authorization\" =\u003e \"Bearer TOKEN\"})\nend\n\ndefmodule Maple.Examples.Github do\n  use Maple\nend\n```\n\n`` will create all the query and mutation functions for the GitHub GraphQL API.\n\nSo you can do the following:\n\n```elixir\niex(1)\u003e c \"examples/github.ex\", \".\" # We need to compile the BEAM file to access the documentation\n[Maple.Examples.Github, Maple.Examples.Github.Config]\n\niex(2)\u003e h Maple.Examples.Github.user\n\n                            def user(params, fields)\n\nLookup a user by login.\n\nParam name: login\n\n  • Description: The user's login.\n  • Type: String\n  • Required: Yes\n\niex(3)\u003e Maple.Examples.Github.viewer(\"login\")\n%Maple.Response{body: %{\"viewer\" =\u003e %{\"login\" =\u003e \"maxneuvians\"}}, status: 200}\n\niex(4)\u003e Maple.Examples.Github.user(%{login: \"maxneuvians\"}, \"name\")\n%Maple.Response{body: %{\"user\" =\u003e %{\"name\" =\u003e \"Max Neuvians\"}}, status: 200}\n\niex(5)\u003e Maple.Examples.Github.user(%{},\"name\")\n{:error, \"Query is missing the following required params: login\"}\n```\n\n`query` functions can are either arity `/1` or `/2` depending if they have required params. `mutation` functions\nare always arity `/2`. Arity `/2` functions always take a `map` as the first argument and a `string` as the second,\nwhich match the GraphQL `params` and `fields` concept.\n\nFunction names are changed from camel to snake case. ex `listUsers` becomes `list_users`.\n\nTake a look at `examples/` for more examples.\n\n## Subscriptions\n\nIt appears that at this point in time the support of subscriptions over web sockets are a work in progress.\n\nFor example, [https://github.com/apollographql/subscriptions-transport-ws/](https://github.com/apollographql/subscriptions-transport-ws/)\nimplements a legacy (`graphql-subscriptions`) and a current (`graphql-ws`) web socket subprotocol for Apollo servers. For more information please take a look here: [https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md)\n\nOnce Absinthe 1.4 has been released I will implement it as an adapter. Here is an example interaction with a Scaphold.io API:\n\n```elixir\niex(1)\u003e Maple.Examples.Scaphold.subscribe_to_post(%{mutations: [\"createPost\"]}, \"mutation value {id content title}\", \u0026Maple.Examples.Scaphold.result/1)\n\n18:40:22.932 [info]  Connected!\n:ok\n18:40:23.432 [info]  Successful subscription\n\niex(2)\u003e Maple.Examples.Scaphold.create_post(%{input: %{title: \"Hello\", content: \"World\"}},\"id\")\n\n18:45:24.977 [info]  Received subscription data\n%{\"data\" =\u003e %{\"subscribeToPost\" =\u003e %{\"mutation\" =\u003e \"createPost\",\n    \"value\" =\u003e %{\"content\" =\u003e \"World\", \"id\" =\u003e \"UG9zdDoxOA==\",\n      \"title\" =\u003e \"Hello\"}}}}\n\n%Maple.Response{body: %{\"createPost\" =\u003e %{\"changedPost\" =\u003e %{\"id\" =\u003e \"UG9zdDoxOA==\"}}},\nstatus\n```\n\n## Options\n\nThe module takes a options from the configuration:\n\n```elixir\nconfig :maple,\n  build_type_structs: false,\n  http_adapter: Maple.Clients.Http,\n  websocket_adapter: Maple.Clients.WebsocketApollo\n```\n\n- `:build_type_structs` - Default is `false`. If set to `true` the macro will create\n  structs for all the fields found in the introspection query. All types are namespaced into\n  `Maple.Types.`\n\n- `:http_adapter` - The default HTTP adapter for completing transactions against the GraphQL\n  server. Default is: `Maple.Clients.Http`\n\n- `:websocket_adapter` - The default Websocket adapter for completing transactions against the GraphQL\n  server using websockets. Default is: `Maple.Clients.WebsocketApollo`\n\n## Installation\n\n```elixir\ndef deps do\n  [{:maple, git: \"https://github.com/maxneuvians/maple\"}]\nend\n```\n\nor\n\n```elixir\ndef deps do\n  [{:maple, \"~\u003e 0.5.0\"}]\nend\n```\n\n## Configuration\n\nIf you only access one GraphQL API you just need to add the following to you config.exs\n\n```elixir\nconfig :maple,\n  build_type_structs: false,\n  http_adapter: Maple.Clients.Http,\n  websocket_adapter: Maple.Clients.WebsocketApollo,\n  api_url: \"URL\",\n  wss_url:, \"WSS_URL\", # If you are using subscriptions over websockets.\n  additional_headers: %{\"Authorization\": \"Bearer TOKEN\"} # If you have any additional headers\n```\n\n## Ramblings\n\nThis library is in development.\n\nContributions and issues welcome!\n\n**Also if you think this is a terrible idea, please let me know!**\n\n## ToDo\n\n- [x] Refactor macro code\n- [x] Add proper documentation\n- [x] Support subscriptions\n- [ ] Support fragments\n- [ ] Look into validation through structs\n- [ ] Alternative syntax for fields\n- [x] Expand help with required attributes\n- [x] Expand help with attribute descriptions\n\n## License\n\nMIT\n\n## Version\n\n0.5.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxneuvians%2Fmaple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxneuvians%2Fmaple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxneuvians%2Fmaple/lists"}