'GraphQL ASP.NET Core Web API Controller returning 500 error

I have a web api controller for GraphQL.

[HttpPost]
        public async Task<IActionResult> Post([FromBody] GraphQLRequestModel query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var inputs = query.Variables.ToInputs();
            var executionOptions = new ExecutionOptions
            {
                Schema = _schema,
                Query = query.Query,
                Inputs = inputs
            };

            var result = await _documentExecuter
                .ExecuteAsync(executionOptions);

            if (result.Errors?.Count > 0)
            {
                return BadRequest(result);
            }

            return Ok(result);
        }

I have the repositories working and gets correct output in GraphiQL Playground. But when trying to hit the controller endpoint from postman, after reading all repositories and coming back to controller, postman shows a 500 error. There is no error thrown until last line of controller. I'm new to GraphQL and doesn't get an idea why this happens. Any suggestion is helpful. I think data does not come back to result variable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source