Skip to content

Instantly share code, notes, and snippets.

View patientplatypus's full-sized avatar

patientplatypus patientplatypus

View GitHub Profile
(ns clojure-play.core
+ .. | (:use [compojure.core :refer :all]
- clojurePlay/ | [compojure.route :as route]
- clojure_play/ | [clojure.data.json :as json]
- doc/ | org.httpkit.server
intro.md | )
+ resources/ | (:gen-class))
- src/ |
- clojure_play/ |(println "in the beginning was the command line...")
core.clj |
This is wrong....
(ns clojure-play.core
+ .. | (:require [compojure.core :refer :all]
- clojurePlay/ | [compojure.route :as route])
- clojure_play/ | org.httpkit.server
- doc/ | )
intro.md | (:gen-class))
but this is ok...
So I'm trying to get next.js/apollo to connect to graphql/elixir-phoenix.
I followed this
https://github.com/lfades/next-with-apollo/issues/13#issuecomment-390289449
to get the next-with-apollo wrapper to be properly configured, and then used this:
https://github.com/absinthe-graphql/absinthe-socket/tree/master/packages/socket-apollo-link
import ApolloClient from 'apollo-client';
import { ApolloLink, split } from 'apollo-link';
import { HttpLink } from 'apollo-link-http'
import { WebSocketLink } from 'apollo-link-ws'
import { setContext } from 'apollo-link-context';
import { onError } from 'apollo-link-error';
import { InMemoryCache } from 'apollo-cache-inmemory'
import { getMainDefinition } from 'apollo-utilities';
import withApollo from 'next-with-apollo'
import Cookies from 'js-cookie';
def update(args, %{context: %{current_user: %{id: id}}}) do
result =
Profile
|> Repo.get(id)
|> (fn user -> if(user == nil, do: %Profile{id: id}, else: user) end).()
|> Profile.changeset(args)
|> Repo.insert_or_update
case result do
{:ok, query} ->
check = Repo.get(User, id) |> Repo.preload([:profile])
def find_profile_by_id(_args, %{context: %{current_user: %{id: id}}}) do
IO.puts "inside find_profile_by_id"
query = from u in User,
join: p in assoc(u, :profile),
where: p.id == ^id,
preload: [profile: p]
repoReturn = Repo.all(query)
{:ok, repoReturn}
def find_profile_by_id(_args, %{context: %{current_user: %{id: id}}}) do
result =
Users
|> Ecto.assoc(:profile)
|> where([u], u.id == ^id)
|> Repo.one()
{:ok, result}
end
def find_profile_by_id(_args, _info) do
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol String.Chars not implemented for %Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}, before_send: [#Function<0.66442134/1 in Plug.Telemetry.call/2>, #Function<0.50969320/1 in Phoenix.LiveReloader.before_send_inject_reloader/2>], body_params: %{"operationName" => nil, "query" => "{\n findProfileById {\n id\n __typename\n }\n}\n", "variables" => %{}}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: "localhost", method: "POST", owner: #PID<0.467.0>, params: %{"operationName" => nil, "query" => "{\n findProfileById {\n id\n __typename\n }\n}\n", "variables" => %{}}, path_info: ["api", "graphiql"], path_params: %{}, port: 4000, private: %{DisplineDiaryWeb.Router => {[], %{Absinthe.Plug.GraphiQL => ["graphiql"]}}, :phoenix_endpoint => DisplineDiaryWeb.Endpoint, :phoenix_format => "json", :phoenix_router => DisplineDiaryWeb.Router, :plug_session_fetch => #Function<1.35161479/1 in Plug.Session.fe
I'm trying to create a token using graphql/absinthe.
So here is my schema:
@desc "Login User"
field :session, :token do
arg :email, non_null(:string)
This weird warning doesn't seem to follow the docs:
```
warning: function Guardian.decode_and_verify/1 is undefined or private. Did you mean one of:
* decode_and_verify/2
* decode_and_verify/3
* decode_and_verify/4
```
Code:
```