Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPropertyValue<int> in your query #1

Open
jeffpatton1971 opened this issue Jun 29, 2021 · 0 comments
Open

GetPropertyValue<int> in your query #1

jeffpatton1971 opened this issue Jun 29, 2021 · 0 comments

Comments

@jeffpatton1971
Copy link

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>()));
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant