Why using aliases in the SDL in GraphQL doesn't work in a nested object when should be valid

Viewed 35

I'm experiencing a strange issue using the aliases in GQL. When I use it inside a nested object I'm getting whatever field I decide to alias the following error

Cannot return null for non-nullable field xxx.yyyy.

Soon as I remove the aliases the value of the field is not null anymore and I cannot explain why this is happening

The original query which fails with alaises

query WEB_GetConsentForms($studyId: ID!) {
  informedConsentForms(
    filter: { isActiveRevision: true, statuses: [PUBLISHED], studyId: $studyId }
    sort: { orderBy: createdAt, direction: DESC }
  ) {
    nodes {
      id
      name: title
      locale
      studyId
      irb {
        id
        attachedSites {
         value: siteId
         label: name
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
  locales(studyId: $studyId) {
    nodes {
      language {
        name
        __typename
      }
      locale
      __typename
    }
    __typename
  }
}

Whatever fields I decide to alias after the IRB is giving me that error. Before the nested field, everything works so for example the field name: title is giving me back the value.

I don't understand why that happens only for the nested fields and as I understood reading online should be valid for doing it this

Screenshots of the data are from autogenerated tests of Cypress so is fake data and safe to show

Valid

enter image description here

Not valid

enter image description here

0 Answers
Related