Skip to content

GetPropertyValue<int> in your query #1

Description

@jeffpatton1971

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions