File tree Expand file tree Collapse file tree 3 files changed +58
-17
lines changed Expand file tree Collapse file tree 3 files changed +58
-17
lines changed Original file line number Diff line number Diff line change 1
1
type Customer {
2
- name : String
3
- city : String
2
+ name : String
3
+ city : String
4
4
}
5
5
type Query {
6
- # An ecmascript generator of customer data.
7
- # Of course, in real life you will call an API or a database. You can do that by changing the `endpoint` argument on the `@rest` directive.
8
- # https://stepzen.com/docs/connecting-backends/how-to-connect-a-rest-service
9
- customer (id : ID ): Customer
10
- @rest (endpoint : " stepzen:empty"
11
- ecmascript : " " "
12
- function transformREST(s) {
13
- var id = get('id')
14
- if (id==1)
15
- return (JSON.stringify({" name ":" John Doe "," city ":" Miami "}))
16
- else
17
- return (JSON.stringify({" name ":" Jane Smith "," city ":" Santa Clara "}))
18
- }
19
- """
6
+ # An ecmascript generator of customer data.
7
+ # Of course, in real life you will call an API or a database. You can do that by changing the `endpoint` argument on the `@rest` directive.
8
+ # https://stepzen.com/docs/connecting-backends/how-to-connect-a-rest-service
9
+ customer (id : ID ! ): Customer
10
+ @rest (
11
+ endpoint : " stepzen:empty"
12
+ ecmascript : " " "
13
+ function transformREST(s) {
14
+ var id = get('id')
15
+ if (id==1)
16
+ return (JSON.stringify({" name ":" John Doe "," city ":" Miami "}))
17
+ else
18
+ return (JSON.stringify({" name ":" Jane Smith "," city ":" Santa Clara "}))
19
+ }
20
+ """
20
21
)
21
- }
22
+ }
Original file line number Diff line number Diff line change
1
+ query Customer ($id : ID ! ) {
2
+ customer (id : $ID ) {
3
+ name
4
+ city
5
+ }
6
+ }
Original file line number Diff line number Diff line change 6
6
7
7
testDescription = getTestDescription ( "snippets" , __dirname ) ;
8
8
9
+ const requestsFile = path . join ( path . dirname ( __dirname ) , "operations.graphql" ) ;
10
+ const requests = fs . readFileSync ( requestsFile , "utf8" ) . toString ( ) ;
11
+
9
12
describe ( testDescription , function ( ) {
13
+ // note tests using no authorization since api is public
10
14
const tests = [
15
+ {
16
+ label : "customer-1" ,
17
+ query : requests ,
18
+ operationName : "Customer" ,
19
+ variables : {
20
+ id :1
21
+ } ,
22
+ expected : {
23
+ customer : {
24
+ name : "John Doe" ,
25
+ city : "Miami" ,
26
+ } ,
27
+ } ,
28
+ authType : authTypes . noAuth ,
29
+ } ,
30
+ {
31
+ label : "customer-2" ,
32
+ query : requests ,
33
+ operationName : "Customer" ,
34
+ variables : {
35
+ id :2
36
+ } ,
37
+ expected : {
38
+ customer : {
39
+ name : "Jane Smith" ,
40
+ city : "Santa Clara" ,
41
+ } ,
42
+ } ,
43
+ authType : authTypes . noAuth ,
44
+ } ,
11
45
]
12
46
return deployAndRun ( __dirname , tests ) ;
13
47
} ) ;
You can’t perform that action at this time.
0 commit comments