Skip to content

schema should support absolute paths #382

Open
@ankon

Description

@ankon

const readSchemaFile =
schemaRelPath => fs.readFileSync(path.join(servicePath, schemaRelPath), { encoding: 'utf8' });
const schemaContent =
Array.isArray(config.schema) ?
mergeTypes(config.schema.map(readSchemaFile)) :
readSchemaFile(config.schema || 'schema.graphql');

This (somewhat explicitly in the name) assumes that the config.schema would be a relative path, but that is not documented.

  1. Is there a particular reason for this requirement, or could this be relaxed?
    diff --git a/src/get-config.js b/src/get-config.js
    index 597e084..17e1764 100644
    --- a/src/get-config.js
    +++ b/src/get-config.js
    @@ -59,7 +59,7 @@ const getConfig = (config, provider, servicePath) => {
       const mappingTemplates = config.mappingTemplates || [];
     
       const readSchemaFile =
    -      schemaRelPath => fs.readFileSync(path.join(servicePath, schemaRelPath), { encoding: 'utf8' });
    +      schemaPath => fs.readFileSync(path.resolve(servicePath, schemaPath), { encoding: 'utf8' });
     
       const schemaContent =
         Array.isArray(config.schema) ?
  2. If there is a reason, would you accept a PR to clarify the documentation?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions