Querying with GraphQL#
-
You’ll need an app for sending and receiving GraphQL queries. We recommend GraphiQL.
- If you’re using Homebrew, you can install it with
brew install --cask graphiql.
- If you’re using Homebrew, you can install it with
-
We need to tell Lagoon Core about the Kubernetes cluster. The GraphQL endpoint is:
https://<YOUR-API-URL>/graphql -
Go to Edit HTTP Headers, and Add Header.
- Header Name:
Authorization - Value:
Bearer YOUR-TOKEN-HERE - In your home directory, the Lagoon CLI has created a
.lagoon.ymlfile. Copy the token from that file and use it for the value here. - Save.
- Header Name:
-
Now you’re ready to run some queries. Run the following test query to ensure everything is working correctly:
-
This should give you the following response:
-
Once you get the correct response, we need to add a mutation.
-
Run the following query:
Add mutationmutation addKubernetes { addKubernetes(input: { name: "<TARGET-NAME-FROM-REMOTE-VALUES.yml>", consoleUrl: "<URL-OF-K8S-CLUSTER>", token: "xxxxxx” routerPattern: "${environment}.${project}.lagoon.example.com" }){id} }name: get fromlagoon-remote-values.ymlconsoleUrl: API Endpoint of Kubernetes cluster. Get fromvalues.yml-
token: get a token for thessh-coreservice account
-
Info
Authorization tokens for GraphQL are very short term so you may need to generate a new one. Run lagoon login and then cat the .lagoon.yml file to get the new token, and replace the old token in the HTTP header with the new one.