' ? 93 | '
' + type + description.slice(3) : 94 | type + description) + '
11 | GraphQL Toolbox is a set of GraphQL tools that aims to help with GraphQL server and client development. 12 | If you would like to experiment with this project, add new tools or improve existing one, then you can find it on the GitHub. 13 |
14 |More tools are coming soon.
*@ 47 | @*' ? 93 | '
' + type + description.slice(3) : 94 | type + description) + '
{this.state.error}109 | Schema definition is based on GraphQL IDL additions. 110 | IDL syntax allows you to define full GraphQL schema with interfaces, types, enums etc. 111 | In order to provide resolution logic for the fields, you can use directives described below. 112 | Directives will define how fields will behave. By default (if no directive is provided), 113 | field resolve function will treat a contextual value as a JSON object and will return it's 114 | property with the same name. 115 |
116 | 117 |120 | directive @httpGet(url: String!, headers: ObjectOrList, query: ObjectOrList, forAll: String) on FIELD_DEFINITION 121 |122 | 123 |
124 | Provides a way to resolve the field with a result of a GET HTTP request.
125 | Supports following arguments:
126 |
url - the URL of an HTTP requestheaders - headers that should be sent with the request.
132 | The value can be either an input object (e.g {`{Authorization: "Bearer FOOBARBAZ"}`})
133 | or a list with name-value pairs (e.g. [{`{name: "Authorization", value: "Bearer FOOBARBAZ"}`}])
134 | query - query string parameters that should be sent with the request.
137 | The value can be either an input object (e.g {`{limit: 10, offset: 0}`})
138 | or a list with name-value pairs (e.g. [{`{name: "page-number", value: "1"}`}])
139 | forAll - A JSON Path expression. For every element,
142 | returned by this expression executed against current context value,
143 | a separate HTTP request would be sent. An elem placeholder
144 | scope may be used in combination with this argument.
145 |
149 | url, headers and query may contain the placeholders which are described below.
150 | value directive may be used in combination with httpGet - it will extract part of the relevant JSON out of the HTTP response.
151 |
154 | directive @const(value: Any!) on FIELD_DEFINITION | SCHEMA 155 |156 | 157 |
158 | Provides a way to resolve a field with a constant value.
159 | value can be any valid GraphQL input value. It would be treated as a JSON value.
160 |
163 | directive @jsonConst(value: String!) on FIELD_DEFINITION | SCHEMA 164 |165 | 166 |
167 | Provides a way to resolve a field with a constant value.
168 | value should be a valid JSON value.
169 |
172 | directive @arg(name: String!) on FIELD_DEFINITION 173 |174 | 175 |
176 | Provides a way to resolve a field with value of one of its arguments. 177 |
178 | 179 |180 | directive @value(name: String, path: String) on FIELD_DEFINITION 181 |182 | 183 |
184 | Extracts a value(s) from the context object. It supports following extractors via arguments (only one can be used): 185 |
186 | 187 |name - Extracts a named property value from a context JSON objectpath - A JSON Path expression. It would be executed against current context JSON value.193 | directive @context(name: String, path: String) on FIELD_DEFINITION 194 |195 | 196 |
197 | Extracts a value(s) from the context object defined on the schema level. It supports following extractors via arguments (only one can be used): 198 |
199 | 200 |name - Extracts a named property value from a JSON objectpath - A JSON Path expression. It would be executed against current context JSON value, which is defined at the schema level.Placeholders may be used in some the directive arguments (inside of the strings) and the syntax looks like this:
208 | 209 |
210 | {`\${value.$.results[0].film}`}
211 |
212 |
213 |
214 | The placeholder consists of two parts separated by dot (.): the scope (value in this case) and
215 | the extractor ($.results[0].film - a JSON Path extractor in this example).
216 | The scope defines a place/value from which you would like extract a value. Following scopes are supported:
217 |
arg - field argumentvalue - a context valuectx - a context value which is defined on a schema levelelem - an extracted element that comes from the forAll argument227 | The extractor can be either a string (the name of the property) or a JSON Path expression. 228 |
229 | 230 |233 | All elements of a schema (like types, fields, arguments, etc.) 234 | support descriptions. Here is an example: 235 |
236 | 237 |{
238 | `"""
239 | The root query type.
240 | """
241 | type Query {
242 | "A character from the StarWars"
243 | person(
244 | "ID of a character"
245 | id: Int!): Person
246 | }`
247 | }
248 |