Open forabi opened 6 years ago
Why is having a build step a problem? We have build steps for pretty much everything.
Does Apollo + graphql-js
provide a solution to this problem? Why don't we use that?
Why is having a build step a problem? We have build steps for pretty much everything.
You're right. But this particular step does not work well in watch mode while I'm developing. I usually have to stop and restart the API server to have Webpack pick up the changes.
But there is another reason why I think (3) is a better option -- it's because the GraphQL SDL is pretty limited compared to TypeScript. For example, there are no generic types so you have to repeat a lot of types:
type NotablePersonEdge {
cursor: ID!
node: NotablePerson!
}
type NotablePersonConnection {
edges: [NotablePersonEdge!]!
pageInfo: PageInfo!
}
type UserEdge {
cursor: ID!
node: User!
}
type UserConnection {
edges: [UserEdge!]!
pageInfo: PageInfo!
}
As we add more connection types, the schema file will get very big.
On the other hand, this could much more concise in TypeScript:
type Edge<Node> = {
cursor: string;
node: Node;
};
type Connection<Node> = {
edges: Edge<Node>[];
pageInfo: PageInfo;
};
type UserConnection = Connection<User>;
type NotablePersonConnection = Connection<NotablePerson>;
Does Apollo + graphql-js provide a solution to this problem? Why don't we use that?
No, I don't think using graphql-js
is a good option. Defining types requires tons of boilerplate.
@forabi I'm okay with TypeGraphQL. If it turns out that it is not the best choice, we can refactor it out.
@wholesomedev I'm not saying that we should use it. I've just recently came across it and I thought it could be useful because it integrates with TS and TypeORM. We'll probably need to think about and experiment with this more.
@forabi sounds good to me 😄
There are few different ways of defining GraphQL schema and the executable resolvers:
graphql
package helper functions. The upside is that we don't need a build step. The downside to this approach: cannot inspect the entire schema easily, very verbose.graphql-js
community.