graphback
graphback copied to clipboard
add fault tolerance plugin
Is your feature request related to a problem? Please describe.
Resiliency against failure e.g
- ability to retry a database query that times intermittently,
- ability to timeout a database query that takes some time to execute,
- falling back to executing a cached query / function after several errors
Describe the solution you'd like
a plugin that declares:
-
@retry
,@timeout
,fallback
annotations to support various fault tolerance pattern. - or that offers a configurable programmatic api to apply the above pattern
Describe alternatives you've considered
This is current achievable by hooking into the created resolvers and compose them into any of your preferably circuit breakeer / fault tolerant js library.
/cc @craicoverflow, @wtrocki Automatically generated comment to notify maintainers
You reading my mind don't you? And have been on fire today! Thank you for logging this issue as I had this somewhat planned when dealing with production ready template.
This is current achievable by hooking into the created resolvers and compose them into any of your preferably circuit breakeer / fault tolerant js library.
I would look for doing this first as bringing more opiniated approaches into graphback might drive off some community. We have multiple ways to compose things (including services) and that might work.
Sorry for snapping issue. We can chat about it at some point
You reading my mind don't you? And have been on fire today! Thank you for logging this issue as I had this somewhat planned when dealing with production ready template.
This is current achievable by hooking into the created resolvers and compose them into any of your preferably circuit breakeer / fault tolerant js library.
I would look for doing this first as bringing more opiniated approaches into graphback might drive off some community. We have multiple ways to compose things (including services) and that might work.
+1 this is a good idea.
Sorry for snapping issue. We can chat about it at some point
Sure, that's the whole idea of opening this issue, to get the discussion going.
Hey, I'd like to work on this issue. What would be a good starting point for this?
Hi @namit-chandwani. Follow the Plugin creation guide and check out the other plugins for help.
We don't have any strict approach for this other than the description provided by @machi1990.
Hey @craicoverflow! I've now got an idea of how plugins work in Graphback by going through the relevant docs.
But there's this one thing that I need help with. Let's say I make some changes in the SchemaCRUDPlugin.ts file.
After that, I move to the packages/create-graphback
directory where I run node dist/index.js Trial-Graphback-Project
to initialize a server named Trial-Graphback-Project
using any one of the Graphback's existing templates.
Then I move into the generated graphback server's directory (ie. Trial-Graphback-Project) where I find the .graphqlrc.yml file, which is configured to use the Schema CRUD Plugin in order to generate the schema.
Now whenever I run the yarn generate
command here, I would want the updated local version of my SchemaCRUDPlugin.ts file to be used for schema generation.
But we know that won't happen, as @graphback/codegen-schema
package present in node_modules is the one which was installed at the start (using yarn install) and not the local one present in packages/graphback-codegen-schema/
, so it does not contain the changes which I had made locally.
So I looked this up on the internet and found a solution which uses the yarn link
command.
I then followed the following steps to link the generated graphback server to the updated local version of the @graphback/codegen-schema
package:
-
cd packages/graphback-codegen-schema/
->yarn link
-
cd packages/create-graphback/Trial-Graphback-Project/
->yarn link @graphback/codegen-schema
But no luck even after following the above steps. Still the locally updated SchemaCRUDPlugin.ts
file is not being used for schema generation.
Is there anything that I'm doing wrong here while using the yarn link
command?
Hey @craicoverflow! I've now got an idea of how plugins work in Graphback by going through the relevant docs.
But there's this one thing that I need help with. Let's say I make some changes in the SchemaCRUDPlugin.ts file.
After that, I move to the
packages/create-graphback
directory where I runnode dist/index.js Trial-Graphback-Project
to initialize a server namedTrial-Graphback-Project
using any one of the Graphback's existing templates.Then I move into the generated graphback server's directory (ie. Trial-Graphback-Project) where I find the .graphqlrc.yml file, which is configured to use the Schema CRUD Plugin in order to generate the schema.
Now whenever I run the
yarn generate
command here, I would want the updated local version of my SchemaCRUDPlugin.ts file to be used for schema generation.But we know that won't happen, as
@graphback/codegen-schema
package present in node_modules is the one which was installed at the start (using yarn install) and not the local one present inpackages/graphback-codegen-schema/
, so it does not contain the changes which I had made locally.So I looked this up on the internet and found a solution which uses the
npm link
command.I then followed the following steps to link the generated graphback server to the updated local version of the
@graphback/codegen-schema
package:
cd packages/graphback-codegen-schema/
->npm link
cd packages/create-graphback/Trial-Graphback-Project/
->npm link @graphback/codegen-schema
But no luck even after following the above steps. Still the locally updated
SchemaCRUDPlugin.ts
file is not being used for schema generation.Is there anything that I'm doing wrong here while using the
npm link
command?
I'd highly appreciate it if you could help me with this, whenever you're free. Thanks in advance!😊 /cc @wtrocki @craicoverflow @machi1990
We use yarn workspaces. If you install project using yarn you will be able to see the changes.
@wtrocki Thank you for the response!
We use yarn workspaces. If you install project using yarn you will be able to see the changes.
Yes, I have been doing the same ie. I installed the project using yarn and used yarn link
.
Sorry I wrote npm link
instead of yarn link
everywhere in my previous comment by mistake (edited that comment now), but yarn workspace is what I'm using too.
I'm not sure what's causing this issue then.
Update 1:
So just now I uninstalled the global version of @graphback/codegen-schema
package and ran both the yarn link
commands once again and now there's some progress, at least now the local version of the SchemaCRUDPlugin.ts file is being considered for schema generation.
So to test it now, I reverted back all of the changes that I made in the SchemaCRUDPlugin.ts file so that's its back to the original version.
But running yarn generate
after that, results in this error due to which the schema generation fails:
namit: ~/Projects/graphback/packages/create-graphback/Trial-Graphback-Project (master)
>> yarn generate
yarn run v1.22.5
$ graphback generate && graphql codegen
<b>Generation failed: Error: Cannot find ObjectTypeComposer with name Note</b>
✔ Parse configuration
✔ Generate outputs
Done in 2.00s.
One important thing to note here is that the SchemaCRUDPlugin.ts file that I'm using here is the original one without any changes made by me, and still it's showing this error.
As I mentioned in my previous comment, this is the approach that I've been following for linking the packages:
cd packages/graphback-codegen-schema/
->yarn link
cd packages/create-graphback/Trial-Graphback-Project/
->yarn link @graphback/codegen-schema
What do you think? Is there anything that I'm doing wrong in the two steps above?