Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: GraphQL API - ability to filter environment variables by field #3790

Open
GROwen opened this issue Aug 6, 2024 · 0 comments

Comments

@GROwen
Copy link

GROwen commented Aug 6, 2024

Motivation

Our team has a requirement to look up specific environment variables. Because we store sensitive data in these variables we would like to be able to filter out those values to limit exposure. This would also improve the developer experience, filtering the payload removes the requirement for post processing.

Current behaviour

We query projects by metadata and return each environments environment variables then run this through jq to filter values for a specific environment variable

curl --location 'https://api.lagoon.amazeeio.cloud/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ******' \
--data-raw '{"query":"query projectsByMetadata ( $type: EnvType, $metadata: [MetadataKeyValue]) {\n
    projectsByMetadata (metadata: $metadata) {\n
        name\n
        envVariables {\n
            name\n
            value\n
        }\n
        environments (type: $type) {\n
            name\n
            envVariables {\n
                name\n
                value\n
            }\n
        }\n
    }\n
} ","variables":{"type":"DEVELOPMENT","metadata":{"key":"type","value":"drupal"}}}'

Desired behaviour

We query projects by metadata and return a specific environment variable based on a field value i.e. "name"

curl --location 'https://api.lagoon.amazeeio.cloud/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ******' \
--data-raw '{"query":"query projectsByMetadata ( $type: EnvType, $metadata: [MetadataKeyValue], $envVar: [EnvironmentVariableKeyValue]) {\n
    projectsByMetadata (metadata: $metadata) {\n
        name\n
        envVariables {\n
            name\n
            value  @filter(op_name: \"=\", value: $envVar[\"name\"])\n
        }\n
        environments (type: $type) {\n
            name\n
            envVariables {\n
                name @filter(op_name: \"=\", value: $envVar[\"name\"])\n
                value\n
            }\n
        }\n
    }\n
} ","variables":{"type":"DEVELOPMENT","metadata":{"key":"type","value":"drupal"},"envVar":{"name":"example"}}}'

Inspiration

I've taken inspiration from the use of directives in this GraphQL implementation. What I like about this is it introduces the ability to set the operator which would be helpful if a user wanted to exclude results i.e. scope != RUNTIME would return all BUILD and GLOBAL variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant