-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from jasonpaulos/client-schema-defs
Add SDL for rest directive
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
scalar RestFunction | ||
union RestFunctionOrString = String | RestFunction | ||
|
||
""" | ||
Set up the endpoint you want to fetch over REST. The rest directive could be used | ||
at any depth in a query, but once it is used, nothing nested in it can be GraphQL | ||
data, it has to be from the RestLink or other resource (like the @client directive) | ||
""" | ||
directive @rest( | ||
""" | ||
The GraphQL type this will return | ||
""" | ||
type: String! | ||
""" | ||
URI-path to the REST API. This could be a path or a full URL. If a path, the | ||
endpoint given on link creation or from the context is concatenated with it to | ||
produce a full `URI`. See also: `pathBuilder` | ||
""" | ||
path: String! | ||
""" | ||
The HTTP method to send the request via (i.e GET, PUT, POST) | ||
""" | ||
method: String | ||
""" | ||
Key to use when looking up the endpoint in the (optional) `endpoints` table if | ||
provided to `RestLink` at creation time. | ||
""" | ||
endpoint: String | ||
""" | ||
If provided, this function gets to control what path is produced for this request. | ||
""" | ||
pathBuilder: RestFunction | ||
""" | ||
This is the name of the variable to use when looking to build a REST request-body | ||
for a `PUT` or `POST` request. It defaults to `input` if not supplied. | ||
""" | ||
bodyKey: String = "input" | ||
""" | ||
If provided, this is the name a `function` that you provided to `variables`, that is | ||
called when a request-body needs to be built. This lets you combine arguments or | ||
encode the body in some format other than JSON. | ||
""" | ||
bodyBuilder: RestFunction | ||
""" | ||
String key to look up a function in `bodySerializers` or a custom serialization | ||
function for the body/headers of this request before it is passed to the fetch call. | ||
Defaults to `JSON.stringify` and setting `Content-Type: application-json`. | ||
""" | ||
bodySerializer: RestFunctionOrString | ||
) on FIELD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters