MCPcopy
hub / github.com/dgraph-io/dgraph / TestCustomGetQuery

Function TestCustomGetQuery

graphql/e2e/custom_logic/custom_logic_test.go:70–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68)
69
70func TestCustomGetQuery(t *testing.T) {
71 schema := customTypes + `
72 type Query {
73 myFavoriteMovies(id: ID!, name: String!, num: Int): [Movie] @custom(http: {
74 url: "http://mock:8888/favMovies/$id?name=$name&num=$num",
75 method: "GET"
76 })
77 }`
78 common.SafelyUpdateGQLSchemaOnAlpha1(t, schema)
79
80 query := `
81 query {
82 myFavoriteMovies(id: "0x123", name: "Author", num: 10) {
83 id
84 name
85 director {
86 id
87 name
88 }
89 }
90 }`
91 params := &common.GraphQLParams{
92 Query: query,
93 }
94
95 result := params.ExecuteAsPost(t, common.GraphqlURL)
96 common.RequireNoGQLErrors(t, result)
97
98 expected := `{"myFavoriteMovies":[{"id":"0x3","name":"Star Wars","director":[{"id":"0x4","name":"George Lucas"}]},{"id":"0x5","name":"Star Trek","director":[{"id":"0x6","name":"J.J. Abrams"}]}]}`
99 require.JSONEq(t, expected, string(result.Data))
100}
101
102func TestCustomPostQuery(t *testing.T) {
103 schema := customTypes + `

Callers

nothing calls this directly

Calls 3

ExecuteAsPostMethod · 0.95
RequireNoGQLErrorsFunction · 0.92

Tested by

no test coverage detected