GraphQL.WebApi
GraphQL.WebApi copied to clipboard
GetPropertyValue<int> in your query
Hey,
Needing to learn GraphQL and found your article which thus far has been handy, but I'm hitting an issue with the query.
Severity Code Description Project File Line Suppression State Error CS1061 'ArgumentValue' does not contain a definition for 'GetPropertyValue' and no accessible extension method 'GetPropertyValue' accepting a first argument of type 'ArgumentValue' could be found (are you missing a using directive or an assembly reference?) HopprQL C:\Users\JeffreyPatton\source\repos\HopprQL\Queries\CustomerQuery.cs 23 Active
I'm getting the red wavy lines under .GetPropertyValue
using GraphQL.Types;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HopprQL.Types;
using HopprQL.Models;
using HopprQL.Contexts;
namespace HopprQL.Queries
{
public class CustomerQuery : ObjectGraphType
{
private readonly CustomerContext _appContext;
public CustomerQuery(CustomerContext appContext)
{
this._appContext = appContext;
Name = "Query";
Field<ListGraphType<CustomerGraphType>>("customers", "Returns a list of Customer", resolve: context => _appContext.Customers.ToList());
Field<CustomerGraphType>("customer", "Returns a Single Customer",
new QueryArguments(new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id", Description = "Customer Id" }),
context => _appContext.Customers.Single(x => x.Id == context.Arguments["id"].GetPropertyValue<int>()));
}
}
}