-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support table relationships in service generators #412
Conversation
…e directories Cell test working
Babel flag --no-copy-ignored has a bug and does not respect our ignored config. For a short term fix, I'm using rimraf package (cross-platform support) to clean up __tests__ folders that shouldn't be in dist/
…s/redwood into pp-add-tests-for-cli-generators
Hmm, I have a dilemma. While this does add relationships to the services, the scaffolds created when there's a relationship are busted. Two reasons:
So we could release this along with a note that scaffolds won't work with it yet. Instead of relationships being 100% broken, they're now only 50% broken. :) Getting data OUT of a service works great, it's inserting that's killing us. Or don't do anything until both problems above are fixed. That probably means more complaints about relationships not being supported in the meantime. :( |
I was working on this but I got stuck because prisma's They just told me that it now does, but it's still in the alpha branch, and I thought |
Great work getting this out the door @cannikin! 🎉 Can't wait to try it out! |
* Remove global mocks, localize to test. * Remove more global mocks. * Make dbCommand tests work again. * Write snapshot tests for generators. * Add generate tests and snaps. * Play around with snapshot testing. * Update snapshots. * Complete reorg of generator files and templates, adds text and fixture directories Cell test working * Component, layout, page and service tests * Adds tests for generator helpers.js * More tests * Comment out some variables that aren't being used for now * Adds multi-word cell tests * Variable name change * Adds multi-word component tests * Component test fix * Adds multi-word layout tests * Adds multi-word page tests * Creates multi-word and CRUD sdl tests * Adds multi word tests for service * Adds scaffold tests * Count actual number of files returned * Rename test directories to __tests__ * Adds tests for src/lib/index * Ignore any files named "test" inside a fixtures directory * Adds generateTemplate tests * Ignore fixture files when linting * fix babel build ignore error using rimraf (rm -rf) Babel flag --no-copy-ignored has a bug and does not respect our ignored config. For a short term fix, I'm using rimraf package (cross-platform support) to clean up __tests__ folders that shouldn't be in dist/ * Converts SDL generator to use same sub-generator technique as scaffold generator * Updates README with new generator file structure * Removes .fixture extensions * Remove unused argument * Adds relations output to service generator * Update SDL tests for service relation creation * Gets scaffold to pass along relations, refactor relation lookup * Reorganize services fixtures * In scaffold cells, don't query for related objects, just foreign keys * Adds helper for extracting foreign key names that are type Int * Automatically cast foreign keys to Int in scaffold generated files Co-authored-by: Peter Pistorius <peter.pistorius@gmail.com> Co-authored-by: Rob Cameron <rob.cameron@fastmail.com> Co-authored-by: David S Price <thedavid@thedavidprice.com>
@cannikin - This closed #327, but I think this actually should have closed #324. #327 was the issue for the generated UI stuff not working, while #324 was the issue for services not properly resolving relation fields. If that's the case, #324 should definitely be closed by this issue, but #327 should probably be reopened, unless this PR is bigger than I've noticed so far. |
#327 was was actually fixed a couple PRs ago. The generated query on the display pages excludes other objects now and only pulls scalar fields. So if you had a |
When generating an SDL, if any tables reference each other via prisma's
@relation
syntax, we will create the equivalent expected resolver syntax in the generated service.Example
The following GraphQL query is not currently supported out of the box with Redwood's implementation of SDL + services. For the given
schema.prisma
:You should be able to write the following GraphQL query:
We will create the following additional functions in the
posts.js
service:And the following functions in the
users.js
service:Apollo will automatically use these relationships to make the GraphQL query above work.
Closes #316
Closes #327