From 739791024ccc7b60d0cd2f0082c40d868e868aef Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Mon, 1 Apr 2019 22:22:40 +0200 Subject: [PATCH] chore(LoggedInUser): Minor improvements in graphql queries --- apps/cf_graphql/lib/resolvers/users.ex | 7 +++++++ apps/cf_graphql/lib/schema/schema.ex | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/cf_graphql/lib/resolvers/users.ex b/apps/cf_graphql/lib/resolvers/users.ex index fce09f63..7a219146 100644 --- a/apps/cf_graphql/lib/resolvers/users.ex +++ b/apps/cf_graphql/lib/resolvers/users.ex @@ -37,6 +37,13 @@ defmodule CF.Graphql.Resolvers.Users do {:ok, user} end + @doc """ + Get logged in user + """ + def get_logged_in(_, _, _) do + {:ok, nil} + end + @doc """ Resolve main picture URL for `user` """ diff --git a/apps/cf_graphql/lib/schema/schema.ex b/apps/cf_graphql/lib/schema/schema.ex index 3117fb20..9edd1e2e 100644 --- a/apps/cf_graphql/lib/schema/schema.ex +++ b/apps/cf_graphql/lib/schema/schema.ex @@ -43,7 +43,6 @@ defmodule CF.Graphql.Schema do @desc "Get logged in user" field :logged_in_user, :user do - middleware(Middleware.RequireAuthentication) resolve(&Resolvers.Users.get_logged_in/3) end @@ -63,6 +62,8 @@ defmodule CF.Graphql.Schema do mutation do @desc "Use this to mark a notifications as seen" field :update_notifications, list_of(:notification) do + middleware(Middleware.RequireAuthentication) + arg(:ids, non_null(list_of(:id))) arg(:seen, non_null(:boolean)) @@ -71,6 +72,8 @@ defmodule CF.Graphql.Schema do @desc "Use this to (un)subscribe from an item notifications" field :update_subscription, :notifications_subscription do + middleware(Middleware.RequireAuthentication) + arg(:scope, non_null(:string)) arg(:entity_id, non_null(:id)) arg(:is_subscribed, non_null(:boolean))