Skip to content

Commit

Permalink
Merge pull request #228 from jasonpaulos/client-schema-defs
Browse files Browse the repository at this point in the history
Add SDL for rest directive
  • Loading branch information
fbartho authored Nov 5, 2019
2 parents 4ed4e83 + e25c9e0 commit 55d7b1f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
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")

0 comments on commit 55d7b1f

Please sign in to comment.