Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Expose data model as GraphQL API #1

Open
infojunkie opened this issue Oct 6, 2018 · 7 comments
Open

Expose data model as GraphQL API #1

infojunkie opened this issue Oct 6, 2018 · 7 comments
Assignees

Comments

@infojunkie
Copy link
Owner

E.g. as per https://medium.com/@govorov/creating-graphql-api-with-koa-and-typeorm-8ec0ce2eaadc

@infojunkie
Copy link
Owner Author

infojunkie commented Oct 13, 2018

Actually, the article above requires recreating all the type definitions manually, which violates DRY. TypeGraphQL only requires decorating existing classes which seems like a much better approach https://github.com/19majkel94/type-graphql

@caiosba caiosba self-assigned this Oct 13, 2018
@caiosba
Copy link
Collaborator

caiosba commented Oct 13, 2018

Thanks, I want to experiment with that a bit tomorrow 😄

@caiosba
Copy link
Collaborator

caiosba commented Oct 15, 2018

I added a GraphQL layer to the application. Now npm run start will start a GraphQL server at http://localhost:4000/graphql and a UI at http://localhost:4000/playground. In order to test, I implemented a first field, courses, which returns all courses, and just one field, label. Attached image shows it in action. Now it's matter of augmenting the schema, e.g., implement other types, their fields and mutations. PR at #8.
graphql

@caiosba
Copy link
Collaborator

caiosba commented Oct 15, 2018

I'll work on a lib that auto-generates basic resolvers (list, get by id, create, update and delete) for typeorm entities.

@infojunkie
Copy link
Owner Author

Looks great so far Caio thanks! And yeah an auto-generated CRUD would be 💃

There are a few read-only entity methods that already exist, e.g. https://github.com/infojunkie/quizzical/blob/master/src/entity/Enrollment.ts#L44 - we would want to expose these to the client. So it would be good to be able to annotate these methods to become fields in the auto-generated entity type or query.

@infojunkie
Copy link
Owner Author

Another option here found on HN today: https://github.com/acro5piano/typed-graphqlify

@infojunkie
Copy link
Owner Author

Picking up where this left off with TypeGraphQL + Apollo Server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants