|
| 1 | +# Appendix: Schema Coordinates |
| 2 | + |
| 3 | +Schema Coordinates are human readable strings that uniquely identify an element defined in a GraphQL Schema. |
| 4 | + |
| 5 | +## Definition |
| 6 | + |
| 7 | +SchemaCoordinates : |
| 8 | + - TypeName FieldSpecifier? |
| 9 | + - InterfaceName FieldSpecifier? |
| 10 | + - EnumName EnumValueSpecifier? |
| 11 | + - @ DirectiveName ArgumentSpecifier? |
| 12 | + - UnionName |
| 13 | + |
| 14 | +FieldSpecifier : |
| 15 | + - . FieldName ArgumentSpecifier? |
| 16 | + |
| 17 | +ArgumentSpecifier : |
| 18 | + - ( ArgumentName ) |
| 19 | + |
| 20 | +EnumValueSpecifier : |
| 21 | + - . EnumValue |
| 22 | + |
| 23 | +## Examples |
| 24 | + |
| 25 | +This section shows example coordinates for the possible schema element types this syntax covers. |
| 26 | + |
| 27 | +All examples below will assume the following schema: |
| 28 | + |
| 29 | +```graphql example |
| 30 | +directive @private(scope: String!) on FIELD |
| 31 | + |
| 32 | +interface Address { |
| 33 | + city: String |
| 34 | +} |
| 35 | + |
| 36 | +type User implements Address { |
| 37 | + name: String |
| 38 | + reviewCount: Int |
| 39 | + friends: [User] |
| 40 | + email: String @private(scope: 'loggedIn') |
| 41 | + city: String |
| 42 | +} |
| 43 | + |
| 44 | +type Business implements Address { |
| 45 | + name: String |
| 46 | + address: String |
| 47 | + rating: Int |
| 48 | + city: String |
| 49 | +} |
| 50 | + |
| 51 | +union Entity = User | Business |
| 52 | + |
| 53 | +enum SearchFilter { |
| 54 | + OPEN_NOW |
| 55 | + DELIVERS_TAKEOUT |
| 56 | + VEGETARIAN_MENU |
| 57 | +} |
| 58 | + |
| 59 | +type Query { |
| 60 | + searchBusiness(name: String!, filter: SearchFilter): Business |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +**Selecting a Type** |
| 65 | + |
| 66 | +Schema Coordinates for the `Business` type: |
| 67 | + |
| 68 | +```example |
| 69 | +Business |
| 70 | +``` |
| 71 | + |
| 72 | +Schema Coordinates for the `User` type: |
| 73 | + |
| 74 | +```example |
| 75 | +User |
| 76 | +``` |
| 77 | + |
| 78 | +**Selecting a Field on a Type** |
| 79 | + |
| 80 | +Schema Coordinates for the `name` field on the `Business` type: |
| 81 | + |
| 82 | +```example |
| 83 | +Business.name |
| 84 | +``` |
| 85 | + |
| 86 | +Schema Coordinates for the `name` field on the `User` type: |
| 87 | + |
| 88 | +```example |
| 89 | +User.name |
| 90 | +``` |
| 91 | + |
| 92 | +**Selecting an Argument on a Field** |
| 93 | + |
| 94 | +Schema Coordinates for the `name` argument on the `searchBusiness` field on the `Query` type: |
| 95 | + |
| 96 | +```example |
| 97 | +Query.searchBusiness(name) |
| 98 | +``` |
| 99 | + |
| 100 | +Schema Coordinates for the `filter` argument on the `searchBusiness` field on the `Query` type: |
| 101 | + |
| 102 | +```example |
| 103 | +Query.searchBusiness(filter) |
| 104 | +``` |
| 105 | + |
| 106 | +**Selecting an Enum** |
| 107 | + |
| 108 | +Schema Coordinates for the `SearchFilter` enum: |
| 109 | + |
| 110 | +```example |
| 111 | +SearchFilter |
| 112 | +``` |
| 113 | + |
| 114 | +**Selecting an Enum Value** |
| 115 | + |
| 116 | +Schema Coordinates for the `OPEN_NOW` value of the`SearchFilter` enum: |
| 117 | + |
| 118 | +```example |
| 119 | +SearchFilter.OPEN_NOW |
| 120 | +``` |
| 121 | + |
| 122 | +**Selecting a Directive Definition** |
| 123 | + |
| 124 | +Schema Coordinates for the `@private` directive definition: |
| 125 | + |
| 126 | +```example |
| 127 | +@private |
| 128 | +``` |
| 129 | + |
| 130 | +**Selecting a Directive Definition Argument** |
| 131 | + |
| 132 | +Schema Coordinates for the `scope` argument on the `@private` directive definition: |
| 133 | + |
| 134 | +```example |
| 135 | +@private(scope) |
| 136 | +``` |
| 137 | + |
| 138 | +**Selecting an Interface** |
| 139 | + |
| 140 | +Schema Coordinates for the `Address` interface: |
| 141 | + |
| 142 | +```example |
| 143 | +Address |
| 144 | +``` |
| 145 | + |
| 146 | +**Selecting a Field on an Interface** |
| 147 | + |
| 148 | +Schema Coordinates for the `city` field on the `Address` interface: |
| 149 | + |
| 150 | +```example |
| 151 | +Address.city |
| 152 | +``` |
| 153 | + |
| 154 | +**Selecting a Union** |
| 155 | + |
| 156 | +Schema Coordinates for the `Entity` union definition: |
| 157 | + |
| 158 | +```example |
| 159 | +Entity |
| 160 | +``` |
| 161 | + |
| 162 | +You may not select members inside a union definition. |
| 163 | + |
| 164 | +```graphql counter-example |
| 165 | +Entity.Business |
| 166 | +``` |
| 167 | + |
| 168 | +In such cases, you may wish to [select the type directly](#sec-Examples.Selecting-a-Type) instead. |
0 commit comments