I have declared a model class like the below.
public class FunctionalOrganization : IOrganization
{
public Guid Id { get; set; }
public string LegalName { get; set; }
public string Name { get; set; }
public IAddress LegalAddress { get; set; }
}
And IAddress interface looks like below
public interface IAddress : IModel
{
string PrimaryLine { get; set; }
string AdditionalLine { get; set; }
string Country { get; set; }
}
And implementation (UnitedStatesAddress) (one of the) of IAddres is like below
public class UnitedStatesAddress : IAddress
{
public string PrimaryLine { get; set; }
public string AdditionalLine { get; set; }
public string Country { get; set; }
public Guid Id { get; set; }
public string City { get; set; }
public string ZipCode { get; set; }
public string State { get; set; }
}
If i want to query the Graphql api to fetch the City, Zip and State from IAddress it is not giving and showing an error.
query {
organizationById (organizationId: "00000000-0000-0000-0000-000000000001"){
legalName
legalAddress {
country
primaryLine
additionalLine
state
}
id
registeredOn
asResponder {
settings {
isVisible
dataCenterLocation
}
}
}
}
and the error looks like below.
{
"errors": [
{
"message": "The field `state` does not exist on the type `Address`.",
"locations": [
{
"line": 8,
"column": 7
}
],
"path": [
"organizationById",
"legalAddress"
],
"extensions": {
"type": "Address",
"field": "state",
"responseName": "state",
"specifiedBy": "http://spec.graphql.org/June2018/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types"
}
}
]
}
Could some one help me how to solve this problem ?