Skip to content
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

fix: refactor graphback to hide unused features #3

Merged
merged 3 commits into from
Sep 14, 2020

Conversation

wtrocki
Copy link
Contributor

@wtrocki wtrocki commented Sep 11, 2020

Motivation

Improve server-side application and lock graphback versions to usable ones.

What was done

  • Use fixed versions of packages (they might break if updated outside the scope so we want to pin them. Renovate is configured to update them together same with github updates

  • Move graphback specific code out of the index for visibility

  • Disable graphback subscriptions as they might be confusing for the users (subscriptions will not deliver the changes in the database as one might expect (they will be only delivering changes that happening thru graphql API.

Why this was done

I wanted to avoid misunderstanding about subscriptions and streaming. Our team will do POC on top of this repository to connect junction stream to the subscriptions - this is for our own needs for the moment it is important to disable queries that might confuse potential developers trying the api.

Verification

I struggled to verify this changes because of the connection details for knex. Our templates use .env files. I have added temporary docker-compose file and tried to run it by

DB_CLIENT=pg && DB_USER=postgresql && DB_PASSWORD=postgres && DB_DATABASE=users && DB_HOST=localhost && DB_PORT=55432 yarn dev

but could not. If you can try if that works for you that will be great.

Copy link
Member

@evanshortiss evanshortiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is really helpful! LGTM, just have some suggestions


const { typeDefs, resolvers, contextCreator } = buildGraphbackAPI(modelDefs, {
crud: {
create: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
create: true,
create: false,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed this feature. Nice to see it exposed like this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. We can enable them on models directly or globally. I felt like in this case global one is needed.

services/iot-graphql-api/src/graphback.ts Outdated Show resolved Hide resolved
services/iot-graphql-api/src/graphback.ts Show resolved Hide resolved
Comment on lines 28 to 33
crud: {
create: false,
update: true,
find: true,
findOne: true,
delete: true,
subCreate: false,
subUpdate: false,
subDelete: false
},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values default to true, so you can just pass the ones you want to change.

Suggested change
crud: {
create: false,
update: true,
find: true,
findOne: true,
delete: true,
subCreate: false,
subUpdate: false,
subDelete: false
},
crud: {
create: false,
subCreate: false,
subUpdate: false,
subDelete: false
},

version: '3'

services:
postgres:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a custom Postgres dockerfile we're using. You can copy this configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is that it provides a pre-seeded DB for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggled to run it - credentials would not allow me to log in for some reason.

Copy link
Member

@evanshortiss evanshortiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @wtrocki - thank you!

@evanshortiss evanshortiss merged commit db63316 into RedHat-Middleware-Workshops:master Sep 14, 2020
@wtrocki wtrocki deleted the graphback branch September 14, 2020 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants