Is it possible to block a variable "property" from entering up in studio traces? Or only the variable as a whole?

Hello Everyone,

I have the following query operation:

query testing($where: ProfileWhereInput) {
 profiles(where: $where){
   id
   email
 }
}

with the following variable:

{ "where": {"email": "name@something.com"} }

What I would like to achieve is preventing the “email” from entering up in the traces of studio. I can achieve this with the following plugin:

ApolloServerPluginUsageReporting({
         sendVariableValues: { exceptNames: ['where'] },
       }),

But this would block the complete “where” variable all together. For instance, the following where var, which I would like to see in traces, would also be completely blocked:

{ "where": {"id": "someid"} }

Is there a way to allow where.id but block where.email. I tried (which didn’t work):

ApolloServerPluginUsageReporting({
         sendVariableValues: { exceptNames: ['email'] },
       }),

I would like to either only allow certain variable properties or deny others? But as far as I can see, these rules only apply to the whole variable. All ideas are welcome?

For a second I thought to have found a solution in using the translate option:

ApolloServerPluginUsageReporting({
          sendVariableValues: { transform: options => {
            options.variables.where.email = '******';
            return options;
          } },

But this has impact on the query execution. The query will also be executed with where { email: “*****”

See also: Surprising behavior if `sendVariableValues.transform` mutates `variables` · Issue #5060 · apollographql/apollo-server · GitHub

Fixed it by doing a deepclone so this post could be closed for now. Still quite a strange behavior tho.

Hello, thanks for the post and followups! Your solution using transform is correct, and you’re also right that this need for a deep copy should be more apparent in the docs.