Date: Fri, 29 Mar 2024 07:04:13 +0000 (UTC) Message-ID: <2134755733.11064.1711695853362@docs.getxray.app> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_11063_2009104212.1711695853361" ------=_Part_11063_2009104212.1711695853361 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Xray provides a GraphQL API that allows users to perform CRUD op= erations directly on Xray entities. GraphQL gives clients the power to ask for exactly what they need = and nothing more, makes it easier to evolve APIs over time, and enables pow= erful developer tools.
Requests made to Xray's GraphQL API must also be authenticated using the= same end point for RE= ST API authentication.
The authentication process uses a Client Id a= nd a Client Secret, both of which are based on an API= Key created for a specific user in Xray Glob= al Settings: API Keys global settings.
Thus, the first step for you is to obtain the token based on the Client = Id and Client Secret of your assigned API Key. You can then use any GraphQL= or REST API end points.
This is just an entry page that contains basic information about GraphQL= API. You can access the complete schema documentation in the following URL= :
GraphQL is introspective. This means you can = query a GraphQL schema for details about itself.
Query __schema
to list all types defined in the s=
chema and get details about each:
query { __schema { types { name kind description fields { name } } } }
Query __type
to get details about any type:
query { __type(name: "Test") { name kind description fields { name } } }
For more information about performing queries, see "Queries= and Mutations."
As with any public API, the Xray GraphQL API protects against excessive = or abusive calls to Xray Cloud's servers.
To pass schema validation, all Xray Cloud Grap= hQL API calls must meet these standards:
limit
argument on any =
;connection.limit
must be within 1-100.These two examples show how to calculate the total number of items in a = call.
{ getTests(limit: 50) { total start limit results { issueId projectId preconditions(limit: 10) { total start limit results { issueId projectId } } } } } Calculation: 50 =3D 50 test issues + 50 x 10 =3D 500 precondition issues =3D 550 total items
{ getTests(limit: 50) { total start limit results { issueId projectId preconditions(limit: 10) { total start limit results { issueId projectId } } testRuns(limit: 50) { total start limit results { id status { name description color } testExecution { issueId projectId testPlans(limit: 5) { total start limit results { issueId projectId } } } } } } } } Calculation: 50 =3D 50 tests + 50 x 10 =3D 500 preconditions + 50 x 50 =3D 2,500 test runs + 50 x 50 x 5 =3D 12,500 test plans =3D 15,550 total items
To pass schema validation, all Xray Cloud Grap= hQL API calls must meet these standards:
These example show how to calculate the total number of resolvers in a c= all.
Query:
{ getTestSets(limit: 50) { results { issueId projectId tests(limit: 10) { results { issueId projectId testType { name } status { name } preconditions(limit: 10) { results { issueId projectId } } } } } } } Calculation: getTestSets + tests + testType + status + preconditions =3D 5 resolvers
Connections let you query related objects as part of the same call. With= connections, you can use a single GraphQL call where you would have to use= multiple calls to a REST API.
It's helpful to picture a graph: dots connected by lines. The dots are n= odes, the lines are edges. A connection defines a relationship between node= s.
Item is a generic term for an object. You can look up a it=
em directly, or you can access related items via a connection. If you speci=
fy a item
that does not return a scalar, you must include subfields until all fields return s=
calars.
Resolver is a generic term for a query, mutation or comple= x field. A complex field is any field in Xray Cloud GraphQL API that is not= a scalar with the exception of the = fields results.
Here are some links that provide extra information and tools related wit= h GraphQL: