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

Custom scalar type mapping does not work with relative paths on Windows #35

Open
DanielRose opened this issue Aug 24, 2020 · 0 comments

Comments

@DanielRose
Copy link

DanielRose commented Aug 24, 2020

The example in the README for a custom scalar type mapping does not work on Windows.

module.exports = {
  endpoint: 'http://example.com/graphql',
  output: 'clients/myClient',
  options: { typeMapper: { location: 'path/to/typeMapper', types: ['Date'] } },
}

The problem is that the output and typeMapper's location are different, so a relative path will be generated (in relativeImportPath.ts). In this case, the relative path would be '../../path/to/typeMapper'

However, the code uses path.relative() to generate that path, which is OS-dependant: Node documentation. On Windows, this will generate the string '..\..\path\to\typeMapper', which is not a valid Node import string. Instead, use path.posix.relative() to force POSIX-compliant paths, even on Windows.

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 a pull request may close this issue.

1 participant