Example #1
0
        /// <summary>
        /// Resolves all queries on guest accesses
        /// </summary>
        /// <param name="graphQlQuery"></param>
        public void ResolveQuery(GraphQlQuery graphQlQuery)
        {
            // LANGUAGES: a list of all lang codes
            graphQlQuery.FieldAsync <BooleanGraphType>(
                "flagExists",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <StringGraphType> > {
                Name = "channelId"
            }
                    ),
                resolve: async(context) =>
            {
                // read user context dictionary
                var userContext = (GraphQlUserContext)context.UserContext;
                var userId      = userContext.GetUserId();

                // require user to be authenticated
                if (userId == null)
                {
                    return(false);
                }

                // map entity to model
                return(await _flagRepository.FlagExists(
                           context.GetArgument <string>("channelId"),
                           userId
                           ));
            }
                );
        }