Schema for nested objects?

I have a question related to this discussion:

In my case, nested property queries are always returning as arrays of one. For instance:

{
  users(func: uid(0x1001)) {
    uid
    firstName
    lastName
    address { # Users will only have 1 address. This should return as an object.
      line1
      line2
      city
      state
      country
      zip
    }
    friends { # Users can have many friends. Even if they have 1, it should return as an array.
      uid
      firstName
      lastName
      address {
        # ...
      }
    }
  }
}

Is there some way I can set up the schema to make sure that address always returns as an object?

If it makes any difference, I’ve been creating the nodes in the database using dgraph-js using dbClient.setSetJson() like so:

const mu = new dgraph.Mutation()
mu.setSetJson({
	firstName: 'Joseph',
	lastName: 'Thomas',
	address: {
		line1: '1234 X street',
		city: 'Los Angeles'
		// ..etc
	}
})

I did not set any schema type for address before making these mutations, and I see that Dgraph has already made one as a uid.

I see that this has been discussed a bit here:

But I don’t see anything in the docs about this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.