{"id":13499529,"url":"https://github.com/peburrows/plot","last_synced_at":"2025-03-29T05:31:41.020Z","repository":{"id":66505424,"uuid":"38930614","full_name":"peburrows/plot","owner":"peburrows","description":"A graphql parser and resolver for Elixir","archived":false,"fork":false,"pushed_at":"2015-12-11T17:46:12.000Z","size":56,"stargazers_count":32,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-01T22:51:23.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peburrows.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-11T15:33:52.000Z","updated_at":"2023-03-20T18:34:28.000Z","dependencies_parsed_at":"2023-04-17T17:48:57.693Z","dependency_job_id":null,"html_url":"https://github.com/peburrows/plot","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/peburrows%2Fplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peburrows%2Fplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peburrows","download_url":"https://codeload.github.com/peburrows/plot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222465393,"owners_count":16989005,"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":[],"created_at":"2024-07-31T22:00:34.309Z","updated_at":"2024-10-31T18:30:43.379Z","avatar_url":"https://github.com/peburrows.png","language":"Elixir","readme":"Plot\n====\nA GraphQL parser and resolver for Elixir.\n\nThis project is still a work in progress, but the eventual goal is to support the full GraphQL spec.\n\n### Basic Usage\n\n*Build a basic AST from a doc*\n```elixir\n\"{\n  user {\n    id,\n    firstName,\n    lastName\n  }\n}\" |\u003e Plot.parse\n# returns:\n{:ok,\n[{:query, nil,\n  [{:object, \"user\", nil, [],\n    [{:field, \"id\", nil, []},\n     {:field, \"firstName\", nil, []},\n     {:field, \"lastName\", nil, []}]}]}]}\n```\n\n*Build Plot objects from a doc*\n```elixir\n\"{\n  user {\n    id,\n    firstName,\n    lastName\n  }\n}\" |\u003e Plot.parse_and_generate\n# returns:\n%Plot.Document{fragments: [],\n operations: [%Plot.Query{name: nil,\n objects:    [%Plot.Object{alias: nil, args: [], name: \"user\",\n              fields: [%Plot.Field{alias: nil, args: [], name: \"lastName\"},\n                       %Plot.Field{alias: nil, args: [], name: \"firstName\"},\n                       %Plot.Field{alias: nil, args: [], name: \"id\"}]}]}],\nvariables:   []}\n```\n\n### Query resolution\n\nQuery resolution works via Elixir protocols. Implement the `Resolution` protocol for the various nodes of your queries.\n\n```elixir\n# Implementation\ndefimpl Plot.Resolution, for: Plot.Object do\n  def resolve(%Plot.Object{name: \"user\"} = _obj, _context) do\n    %{\"firstName\" =\u003e \"Phil\", \"lastName\" =\u003e \"Burrows\", dontInclude: \"this\"}\n  end\n\n  def resolve(%Plot.Object{name: \"birthday\"}, _context) do\n    %{\"day\" =\u003e 15, \"month\" =\u003e 12, \"year\" =\u003e 2015}\n  end\nend\n\n# Resolution\ndoc = \"{user {firstName, lastName, birthday {month, year}}}\" |\u003e Plot.parse_and_generate\ndoc.operations |\u003e Enum.at(0) |\u003e Plot.Resolver.resolve\n# returns:\n[%{\"user\" =\u003e %{\"birthday\" =\u003e %{\"month\" =\u003e 12, \"year\" =\u003e 2015},\n   \"firstName\" =\u003e \"Phil\", \"lastName\" =\u003e \"Burrows\"}}]\n```\n","funding_links":[],"categories":["Libraries","Implementations"],"sub_categories":["Elixir Libraries","Elixir"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeburrows%2Fplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeburrows%2Fplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeburrows%2Fplot/lists"}