| 
1 | 1 | = Using your GraphQL API  | 
2 | 2 | 
 
  | 
3 |  | -== Query your GraphQL API  | 
 | 3 | +== Querying your GraphQL API  | 
4 | 4 | 
 
  | 
5 |  | -Once the status for the GraphQL API is `ready` you can send GraphQL requests to it. As all requests are subject to authentication, you must include an API key or JWT token.  | 
 | 5 | +When the status for the GraphQL API is "ready" you can send GraphQL requests to it.  | 
 | 6 | +As all requests are subject to authentication, you must include an API key or JWT token.  | 
6 | 7 | 
 
  | 
7 |  | -=== With an API Key Authentication Provider  | 
 | 8 | +=== With an API Key authentication provider  | 
8 | 9 | 
 
  | 
9 |  | -Add `x-api-key: YOUR_API_KEY` to the header of the request. For example, with curl replacing the UPPERCASE values with those of your own:  | 
 | 10 | +Add `x-api-key: YOUR_API_KEY` to the header of the request.  | 
 | 11 | +For example, with cURL and replacing the UPPERCASE values with those of your own:  | 
10 | 12 | 
 
  | 
11 | 13 | [source, bash, indent=0]  | 
12 | 14 | ----  | 
13 | 15 | curl --location YOUR_GRAPHQL_API_URL --header 'Content-Type: application/json' --header 'x-api-key: YOUR_API_KEY' --data 'YOUR_GRAPHQL_QUERY'  | 
14 | 16 | ----  | 
15 | 17 | 
 
  | 
16 |  | -=== With a JWKS Authentication Provider  | 
 | 18 | +=== With a JWKS authentication provider  | 
17 | 19 | 
 
  | 
18 |  | -Obtain a JWT from your identity provider. Using the JWT, add `Authorization: Bearer YOUR_JWT` to the headers of the request.  | 
 | 20 | +Obtain a JWT from your identity provider.  | 
 | 21 | +Using the JWT, add `Authorization: Bearer YOUR_JWT` to the headers of the request.  | 
19 | 22 | 
 
  | 
20 |  | -For example, with curl replacing the UPPERCASE values with those of your own:  | 
 | 23 | +For example, with cURL and replacing the UPPERCASE values with those of your own:  | 
21 | 24 | 
 
  | 
22 | 25 | [source, bash, indent=0]  | 
23 | 26 | ----  | 
24 | 27 | curl --location  YOUR_GRAPHQL_API_URL --header 'Authorization: Bearer YOUR_JWT'--header 'Content-Type: application/json --data 'YOUR_GRAPHQL_QUERY'  | 
25 | 28 | ----  | 
26 | 29 | 
 
  | 
27 |  | -== Query your GraphQL API from a Browser  | 
 | 30 | +== Querying your GraphQL API from a browser  | 
28 | 31 | 
 
  | 
29 |  | -=== CORS (Cross-Origin Resource Sharing) Policy  | 
 | 32 | +=== CORS Policy  | 
30 | 33 | 
 
  | 
31 |  | -For security reasons, browsers restrict cross-origin requests to servers. This means that by default, if you configure a web app to make a request to your GraphQL APIs from a browser, it will fail. This is because your web app will be hosted at a different origin from your GraphQL API.  | 
 | 34 | +For security reasons, browsers restrict cross-origin requests to servers.  | 
 | 35 | +This means that by default, if you configure a web app to make a request to your GraphQL APIs from a browser, it will fail.  | 
 | 36 | +This is because your web app is hosted at a different origin than your GraphQL API.  | 
32 | 37 | 
 
  | 
33 |  | -However, most modern browsers support Cross-Origin Resource Sharing. This involves the browser sending a “preflight” request to the server to check that it will allow the actual request. You can configure your GraphQL APIs to allow cross-origin requests from your web app by adding it to the list of allowed origins. For example, if you expect requests to be made by a web app hosted at https://example.com, this should be added to the list of allowed origins for your GraphQL API.  | 
 | 38 | +However, most modern browsers support Cross-Origin Resource Sharing (CORS).  | 
 | 39 | +This involves the browser sending a "preflight" request to the server to check that it will allow the actual request.  | 
 | 40 | +You can configure your GraphQL APIs to allow cross-origin requests from your web app by adding it to the list of allowed origins.  | 
 | 41 | +For example, if you expect requests to be made by a web app hosted at `https://example.com`, this should be added to the list of allowed origins for your GraphQL API.  | 
34 | 42 | 
 
  | 
35 | 43 | [NOTE]  | 
36 | 44 | ====  | 
37 |  | -Only exact matches for allowed origins are supported - wildcards (*) will not work  | 
 | 45 | +Only exact matches for allowed origins are supported - wildcards (*) will do not work.  | 
38 | 46 | ====  | 
39 | 47 | 
 
  | 
40 |  | -This can be done using the aura-cli using the following command, replacing the UPPERCASE values as required:  | 
 | 48 | +Use the aura-cli and the following command, replacing the UPPERCASE values as required:  | 
41 | 49 | 
 
  | 
42 | 50 | [source, bash, indent=0]  | 
43 | 51 | ----  | 
 | 
0 commit comments