GraphQL exception thrown c#. GraphQL.Parser.SourceException:

1

I am trying implementing the following tool: https://github.com/ckimes89/graphql-net

I'm having a bit of an issue with GraphQL. I'm trying to query my dataset but I'm running into problems the moment I try to execute a query. I get the exception:

GraphQL.Parser.SourceException: 'field ``user'' is a value type and cannot be selected from'

My code is as follows:

 public void test() {
     var schema = GraphQL<AdtDbContext>.CreateDefaultSchema(() => new AdtDbContext());
     schema.AddType<NTC_TC_MAINS>().AddAllFields();            
     var gql = new GraphQL<AdtDbContext>(schema);
     schema.AddField("user", new { NAME = "-1" }, (db, args) => db.NTC_TC_MAINS.SingleOrDefault(u => u.TC_NAME == args.NAME));
     schema.Complete();
     var qresult = gql.ExecuteQuery("{user(NAME:\"Hudson\") {tC_NAME}}");
     Console.WriteLine(JsonConvert.SerializeObject(qresult, Formatting.Indented));
    }

With the following DBset:

public DbSet<NTC_TC_MAINS> NTC_TC_MAINS { get; set; }

typeselectedfrom

The exception is as follows is as follows:

GraphQL.Parser.SourceException occurred
  HResult=0x80131500
  Message=field ``user'' is a value type and cannot be selected from
  Source=GraphQL.Parser
  StackTrace:
<Cannot evaluate the exception stack trace>

I am able to query previous examples from the github examples page but the moment I get my own data, the above exception gets thrown. Any help would be appreciated!

c#
.net
entity-framework-6
graphql
asked on Stack Overflow Mar 26, 2018 by user2643892 • edited Mar 26, 2018 by s952163

1 Answer

0

My NTC_TC_MAINS was accidentally referenced twice. GraphQL failed with the execute query as a result.

answered on Stack Overflow Mar 27, 2018 by user2643892

User contributions licensed under CC BY-SA 3.0