HriBB / graphql-server-express-upload

Graphql Server Express file upload middleware
MIT License
41 stars 5 forks source link

Kind.x in function parseJSONLiteral(ast) #2

Closed sandervanhooft closed 8 years ago

sandervanhooft commented 8 years ago

Hi @HriBB,

In the readme.md file the function parseJSONLiteral(ast) references Kind.STRING, Kind.BOOLEAN, Kind.INT, Kind.FLOAT, Kind.OBJECT.

Where are these coming from? / How should I define them?

From the readme.md:

function parseJSONLiteral(ast) {
  switch (ast.kind) {
    case Kind.STRING:
    case Kind.BOOLEAN:
      return ast.value;
    case Kind.INT:
    case Kind.FLOAT:
      return parseFloat(ast.value);
    case Kind.OBJECT: {
      const value = Object.create(null);
      ast.fields.forEach(field => {
        value[field.name.value] = parseJSONLiteral(field.value);
      });

      return value;
    }
    case Kind.LIST:
      return ast.values.map(parseJSONLiteral);
    default:
      return null;
  }
}
sandervanhooft commented 8 years ago

I just stumbled upon the solution from the apollo docs: import { Kind } from 'graphql/language'; This means graphql also should be a peer dependency.

thebigredgeek commented 8 years ago

@sandervanhooft did you reopen this on purpose?

sandervanhooft commented 8 years ago

Hi @thebigredgeek . Yes, because of the graphql dependency.

In issue #1 it's mentioned that peer dependencies are no more... Consider to put graphql into dependencies?

Feel free to close if this dependency is not an issue.

HriBB commented 8 years ago

Hey guys, I'm really busy ATM, so if you want, you can make a PR to fix this. Otherwise, I'll try to fix is ASAP.

sandervanhooft commented 8 years ago

I'm using "graphql": "^0.7.2",, will try to make a PR soon

thebigredgeek commented 8 years ago

Honestly I think the solution here is to provide the scalar definition in the package. Adding a dependency just so that another package cab require it sounds like bad engineering