Skip to content

Conversation

theleeeo
Copy link
Contributor

Okay, this is a fun one:

Currently, there is a bug where generation will fail in the case of:

  1. After the link directive the string "url:" is present somewhere else
  2. Then there is a double qoute in any way (likely to be encountered because of multiline comments)
  3. After that there is a closing parenthesis somewhere (can found in comments and enclosing input parameters)

All of this is because of a bug in the regex for extracting the version of the federation from the url. It it fixed in this pr by only allowing whitespace to come between the "url" in the @link and its first double qoute.

Here is a minimal example showing it in action:

extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: [])

type Foo {
  url: String
}

"""
Multiline comment has double qoutes
"""
type Bar {
  field: String # A comment with a parenthesis (not good)
}

I have:

  • Added tests covering the bug / feature (see testing)
  • [ x ] Updated any relevant documentation (see docs)

@coveralls
Copy link

Coverage Status

coverage: 73.029% (+0.03%) from 72.995%
when pulling a9d4312 on theleeeo:regex-fix
into eadb1db on 99designs:master.

@StevenACoffman
Copy link
Collaborator

StevenACoffman commented Apr 23, 2025

Wow, thank you... and I super regret that these are regexes in the first place. 😅

Some people, when confronted with a problem, think
“I know, I'll use regular expressions.” Now they have two problems.

Jamie Zawinski

@StevenACoffman StevenACoffman merged commit 55ea812 into 99designs:master Apr 23, 2025
17 checks passed
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

Successfully merging this pull request may close these issues.

3 participants