permalink | editLink | sidebar | title |
---|---|---|---|
/helpers/GraphQL | false | auto | GraphQL |
Extends Helper
GraphQL helper allows to send additional requests to a GraphQl endpoint during acceptance tests. Axios library is used to perform requests.
- endpoint: GraphQL base URL
- timeout: timeout for requests in milliseconds. 10000ms by default
- defaultHeaders: a list of default headers
- onRequest: a async function which can update request object.
GraphQL: {endpoint: 'http://site.com/graphql/',onRequest: (request)=>{request.headers.auth='123';}}
Send GraphQL requests by accessing _executeQuery
method:
this.helpers['GraphQL']._executeQuery({ url, data,});
config
Executes query via axios call
request
object
Prepares request for axios call
Send query to GraphQL endpoint over http
I.sendMutation(` mutation createUser($user: UserInput!) { createUser(user: $user) { id name email } } `,{user: {name: 'John Doe',email: 'john@xmail.com'}},});
mutation
Stringvariables
object that may go along with the mutationoptions
object are additional query optionsheaders
object
Send query to GraphQL endpoint over http. Returns a response as a promise.
constresponse=awaitI.sendQuery('{ users { name email }}');// with variablesconstresponse=awaitI.sendQuery('query getUser($id: ID) { user(id: $id) { name email }}',{id: 1},)constuser=response.data.data;