GraphQL.WebApi icon indicating copy to clipboard operation
GraphQL.WebApi copied to clipboard

GetPropertyValue<int> in your query

Open jeffpatton1971 opened this issue 3 years ago • 0 comments

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() and basically there is no huge difference between what I have and what is in this code. Just looking for a little advice on how to resolve this.

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>()));
        }
    }
}

jeffpatton1971 avatar Jun 29 '21 21:06 jeffpatton1971