-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphql: Support queries from custom HTTP endpoints. (#5004)
This PR supports types with @not_dgraph directive and allows us to specify the @Custom directive for queries. For types with @not_dgraph directives, queries, mutations and other types are not generated. Queries with @Custom directive, are sent to the remote endpoint and the result returned is validated against the specified schema.
- Loading branch information
1 parent
da208cd
commit 34790b1
Showing
45 changed files
with
1,433 additions
and
53 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
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,193 @@ | ||
- | ||
name: "custom GET query returning users" | ||
gqlquery: | | ||
query { | ||
myFavoriteMovies(id: "0x1", name: "Michael") { | ||
id | ||
name | ||
director { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
httpresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
{ | ||
"id": "0x1", | ||
"name": "Star Wars", | ||
"director": [ | ||
{ | ||
"id": "0x2", | ||
"name": "George Lucas" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek" | ||
} | ||
] | ||
} | ||
url: http://myapi.com/favMovies/0x1?name=Michael&num= | ||
method: GET | ||
resolvedresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
{ | ||
"id": "0x1", | ||
"name": "Star Wars", | ||
"director": [ | ||
{ | ||
"id": "0x2", | ||
"name": "George Lucas" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek", | ||
"director": [] | ||
} | ||
] | ||
} | ||
- | ||
name: "custom GET query returning users one of which becomes null" | ||
gqlquery: | | ||
query { | ||
myFavoriteMovies(id: "0x1", name: "Michael") { | ||
id | ||
name | ||
director { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
httpresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
{ | ||
"id": "0x1", | ||
"director": [ | ||
{ | ||
"id": "0x2", | ||
"name": "George Lucas" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek" | ||
} | ||
] | ||
} | ||
url: http://myapi.com/favMovies/0x1?name=Michael&num= | ||
method: GET | ||
resolvedresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
null, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek", | ||
"director": [] | ||
} | ||
] | ||
} | ||
- | ||
name: "custom GET query gets URL filled from GraphQL variables" | ||
gqlquery: | | ||
query users($id: ID!) { | ||
myFavoriteMovies(id: $id, name: "Michael Compton", num: 10) { | ||
id | ||
name | ||
director { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
variables: { "id": "0x9" } | ||
httpresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
{ | ||
"id": "0x1", | ||
"director": [ | ||
{ | ||
"id": "0x2", | ||
"name": "George Lucas" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek" | ||
} | ||
] | ||
} | ||
url: http://myapi.com/favMovies/0x9?name=Michael+Compton&num=10 | ||
method: GET | ||
resolvedresponse: | | ||
{ | ||
"myFavoriteMovies": [ | ||
null, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek", | ||
"director": [] | ||
} | ||
] | ||
} | ||
- | ||
name: "custom POST query gets body filled from variables" | ||
gqlquery: | | ||
query movies($id: ID!) { | ||
myFavoriteMoviesPart2(id: $id, name: "Michael", num: 10) { | ||
id | ||
name | ||
director { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
variables: { "id": "0x9" } | ||
httpresponse: | | ||
{ | ||
"myFavoriteMoviesPart2": [ | ||
{ | ||
"id": "0x1", | ||
"director": [ | ||
{ | ||
"id": "0x2", | ||
"name": "George Lucas" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek" | ||
} | ||
] | ||
} | ||
url: http://myapi.com/favMovies/0x9?name=Michael&num=10 | ||
method: POST | ||
body: '{ "id": "0x9", "name": "Michael", "director": { "number": 10 }}' | ||
headers: { "X-App-Token": ["val"], "Auth0-Token": ["tok"] } | ||
resolvedresponse: | | ||
{ | ||
"myFavoriteMoviesPart2": [ | ||
null, | ||
{ | ||
"id": "0x3", | ||
"name": "Star Trek", | ||
"director": [] | ||
} | ||
] | ||
} |
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
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
Oops, something went wrong.