demo-elixir-phoenix-graphql-vue

Demo of Elixir, Phoenix, GraphQL, Vue.js

https://github.com/joelparkerhenderson/demo-elixir-phoenix-graphql-vue

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.3%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

Demo of Elixir, Phoenix, GraphQL, Vue.js

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Default Branch: master
  • Homepage:
  • Size: 63.5 KB
Statistics
  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Created over 7 years ago · Last pushed about 1 year ago
Metadata Files
Readme Citation

README.md

Demo of Elixir, Phoenix, GraphQL, Vue.js

Credit: https://codeburst.io/how-to-setup-graphql-vue-js-and-phoenix-1-3-part-1-the-backend-e3305641e5c

Create:

sh mix phx.new demo --no-brunch

Edit ./mix.deps to add Absinthe, Poison, and change Cowbow to be a plug:

elixir defp deps do [ {:phoenix, "~> 1.3.0"}, {:phoenix_pubsub, "~> 1.0"}, {:phoenix_ecto, "~> 3.2"}, {:postgrex, ">= 0.0.0"}, {:phoenix_html, "~> 2.10"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.11"}, {:plug_cowboy, "~> 1.0"}, {:absinthe, "~> 1.4.0"}, {:absinthe_plug, "~> 1.4"}, {:poison, "~> 3.1.0"} ] end

Run:

sh mix deps.get

Edit ./lib/demo_web/router.ex to append:

```elixir forward "/graphql", Absinthe.Plug, schema: DemoWeb.Schema

forward "/graphiql", Absinthe.Plug.GraphiQL, schema: DemoWeb.Schema, interface: :simple ```

Edit ./lib/demo_web/endpoint.ex to add the Absinthe plug parser:

elixir parsers: [:urlencoded, :multipart, :json, Absinthe.Plug.Parser],

Create ./lib/demo_web/schema.ex:

```elixir defmodule DemoWeb.Schema do use Absinthe.Schema importtypes Absinthe.Type.Custom importtypes DemoWeb.Schema.AccountTypes alias DemoWeb.Resolvers

query do

@desc "Get a user"
field :user, :user do
  arg :id, non_null(:id)
  resolve &Resolvers.Accounts.find_user/3
end

end

end ```

Create a folder for resolvers:

sh mkdir ./lib/demo_web/resolvers

Create a file ./lib/demo_web/resolvers/accounts.ex:

elixir defmodule DemoWeb.Resolvers.Accounts do def find_user(_parent, %{id: id}, _resolution) do case Demo.Accounts.find_user(id) do nil -> {:error, "User ID #{id} not found"} user -> {:ok, user} end end end

Create a file ./lib/demo/accounts.ex:

elixir defmodule Demo.Accounts do # Stubbed out for now. def find_user(id) do %{ name: "Alice Adams", id: id } end end

Create a folder for web schema types:

sh mkdir ./lib/demo_web/schema

Create a file ./lib/demo_web/schema/account_types.ex:

```elixir defmodule DemoWeb.Schema.AccountTypes do use Absinthe.Schema.Notation

@desc "A user" object :user do field :id, :id # clients can get the user id field :name, :string # clients can also ask for the name field end end ```

Edit file ./lib/demo_web/templates/layout/app.html.eex to change the body tag to:

html <body> <%= render @view_module, @view_template, assigns %> <script src="<%= static_path(@conn, "/js/app.js") %>"></script> </body>

Edit file ./lib/demo_web/templates/page/index.html.eex to replace the entire file with this:

html <div id=”app”></div>

Run this to create the database:

sh mix ecto.create

Run this to launch the server:

sh iex -S mix phx.server

Browse http://localhost:4000/graphiql

Try a query such as:

graphql { user(id: 1) { name } }

Result:

json { "data": { "user": { "name": "Alice Adams" } } }

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo of Elixir, Phoenix, GraphQL, Vue.js
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo-elixir-phoenix-graphql-vue/'
    description: Demo of Elixir, Phoenix, GraphQL, Vue.js
repository-code: 'https://github.com/joelparkerhenderson/demo-elixir-phoenix-graphql-vue/'
abstract: >-
  Demo of Elixir, Phoenix, GraphQL, Vue.js
license: See license file

GitHub Events

Total
Last Year

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 2
  • Total Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 2
Committer Domains (Top 20 + Academic)

Dependencies

demo/mix.exs hex
  • absinthe ~> 1.4.0
  • absinthe_plug ~> 1.4
  • gettext ~> 0.11
  • phoenix ~> 1.3.0
  • phoenix_ecto ~> 3.2
  • phoenix_html ~> 2.10
  • phoenix_live_reload ~> 1.0
  • phoenix_pubsub ~> 1.0
  • plug_cowboy ~> 1.0
  • poison ~> 3.1.0
  • postgrex >= 0.0.0
demo/mix.lock hex
  • absinthe 1.4.13
  • absinthe_plug 1.4.6
  • connection 1.0.4
  • cowboy 1.1.2
  • cowlib 1.0.2
  • db_connection 1.1.3
  • decimal 1.5.0
  • ecto 2.2.11
  • file_system 0.2.6
  • gettext 0.16.0
  • mime 1.3.0
  • phoenix 1.3.4
  • phoenix_ecto 3.6.0
  • phoenix_html 2.12.0
  • phoenix_live_reload 1.1.7
  • phoenix_pubsub 1.1.1
  • plug 1.7.1
  • plug_cowboy 1.0.0
  • plug_crypto 1.0.0
  • poison 3.1.0
  • poolboy 1.5.1
  • postgrex 0.13.5
  • ranch 1.3.2