ardatan / ardatan/graphql-mesh

Incorrect docs for string interpolation

Open
#2,004 2 comments 2 reactions 0 assignees View on GitHub
documentation
Dominant language
TypeScript
Stars
3.5k
Forks
363
Avg merge
6h 10m
Merged PRs (30d)
19

Description

String interpolation does not strip whitespace from values or modifiers. This isn't necessarily a bug but is not clarified anywhere and does mean that the docs are wrong.

Deriving a reproduction from [transform-cache's cache key example](https://www.graphql-mesh.com/docs/transforms/cache#the-cache-key) which should interpolate the current date:

> ```
> cacheKey: user-{args.id}-{yyyy-mm-dd | date}
> ```

We can see that the output is not as expected.

```
> stringInterpolator.parse("{yyyy-mm-dd | date}")
''
```

This is because there is whitespace in the modifier name which we can demonstrate by registering a modifier with that whitespace.

```
> stringInterpolator.registerModifier(" date", () => "Oops!")
Interpolator {}
> stringInterpolator.parse("{yyyy-mm-dd | date}"));
'Oops!'
```

The correct behaviour is to remove the whitespace from the interpolation template.

```
> stringInterpolator.parse("{yyyy-mm-dd|date}")
'2021-24-22'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the stringInterpolator API and the linked transform-cache cache key example, then compare the documented interpolation syntax with the parse and registerModifier examples in the issue. Update the relevant documentation to state whitespace handling and make the cache-key example match the demonstrated behavior; verify the examples against the shown parse calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.