Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions schema.graphql
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
1 change: 1 addition & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ node -e "var package = require('./package.json'); \
# Copy few more files to ./npm
cp README.md npm/
cp LICENSE npm/
cp schema.graphql npm/

echo "deploying to npm…"
(cd npm && npm publish) || (>&2 echo "If this failed with ENEEDAUTH, remember that 'yarn deploy' won't work because yarn hot-patches npm's registry to yarn pkg.com")