nicolasdao / graphql-s2s

Add GraphQL Schema support for type inheritance, generic typing, metadata decoration. Transpile the enriched GraphQL string schema into the standard string schema understood by graphql.js and the Apollo server client.
Other
187 stars 15 forks source link

Feature request: add a flag to transpileSchema to skip schema checks #39

Open healqq opened 4 years ago

healqq commented 4 years ago

Hello! I was trying to make type inheritance work in graphql and your library is perfect for this. There is just one small issue that doesn't let me use it out of the box: when I call transpileSchema - it runs some checks, for example this one: https://github.com/nicolasdao/graphql-s2s/blob/master/src/graphqls2s.js#L894. And it breaks in case of schema stiching. In my pipeline I use .graphql files and I made a very simple loader:

const { transpileSchema } = require('graphql-s2s').graphqls2s;

module.exports = (source) => {
  const schema = transpileSchema(source);
  console.log(schema);
  return schema;
}

this runs before graphql-tag loader and it works just fine if I comment out those interface checks. Would be nice if there was a flag that could ignore those checks if it's passed. I can probably contribute, but would be nice if you could point what other places should be affected by that flag.

nicolasdao commented 4 years ago

Thanks a lot for your feature request @healqq. We're glad to hear that you find our lib helpful.

We'll deal with your request asap.

Have a great weekend.

Cheers,

Nic

nicolasdao commented 4 years ago

Hi @healqq ,

Do you think you could give me some examples to recreate that issue? I need that example to build some unit tests and make sure all is ok.

Thanks.

Nic

healqq commented 4 years ago

@nicolasdao something like that should work:

// index.js
import { transpileSchema } from 'graphql-s2s';
const type = `
type Entity implements Identifiable {
  id: Int!
}
`;
// Should not throw an exception that Identifiable is not defined
const schema = transpileSchema(type);
nicolasdao commented 4 years ago

Awesome @healqq. Thanks.