GraphQL的query是?在object上选择要查询的field

{
  hero {
    name
    appearsIn
  }
}
{
  "data": {
    "hero": {
      "name": "R2-D2",
      "appearsIn": [
        "NEWHOPE",
        "EMPIRE",
        "JEDI"
      ]
    }
  }
}

Type language, Object types and fields

type Character {
  name: String!
  appearsIn: [Episode!]!
  length(unit: LengthUnit = METER): Float
}
  • Character: object
  • String: built-in scalar type
  • String!: non-nullable
  • [Episode!]!: an array of Episode objects, non-nullable but can be zero item
  • length
    • unit: argument
    • METER: default value of unit

Scalar types

  • fields don’t have sub-fields
  • default scalar types: Int, Float, String, Boolean, ID
  • custom scalar type: scalar Date