@embedded directive

Specifies that the type should be embedded within any types referring to this type.

Schema location

This directive is valid in a Type declaration within a GraphQL schema.

Arguments

None.

Description

The @embedded directive marks the annotated type as an embedded type. Embedded types do not have their own associated collection; the data for an embedded type is stored within the parent type.

Example

Given the following GraphQL schema:

type User {
  name: String
  address: Address
}

type Address @embedded {
  street: String!
  city: String!
  zipCode: String!
}

You could create a user and address with the following mutation:

mutation {
  createUser(
    data: {
      name: "Mary"
      address: {
        street: "Market street, 1023"
        city: "San Francisco"
        zipCode: "91044"
      }
    }
  ) {
    _id
  }
}

The resulting document within Fauna would look like:

Get(Ref(Collection("User")
{ ref: Ref(Collection("User"), "235155496629174791"),
  ts: 1560520607525000,
  data:
   { name: 'Mary',
     address:
      { street: 'Market street, 1023',
        city: 'San Francisco',
        zipCode: '91044' } } }

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!