Skip to content

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

@DanielRose

Description

@DanielRose

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions