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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with the relay plugin #3

Closed
vecerek opened this issue Jul 17, 2023 · 5 comments
Closed

Integration with the relay plugin #3

vecerek opened this issue Jul 17, 2023 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@vecerek
Copy link
Contributor

vecerek commented Jul 17, 2023

Hi there 馃憢 I'm just about to start using Effect in one of my existing projects and would love to try your plugin. One thing I noticed during the migration was that there's a missing integration with the relay plugin that I use for declaring mutations like so:

builder.relayMutationField(
  "resourceCreate",
  {
    inputFields: (t) => ({
      a: t.string(),
    }),
  },
  {
    errors: {
      directResult: true,
      types: [
        FeatureUnavailableError,
        ForbiddenError,
        InvalidInputError,
        LimitReachedError,
      ],
    },
    resolve: async (_root, _args, _env) => ({
      resource: { /* blah blah blah */ },
    }),
  },
  {
    outputFields: (t) => ({
      resource: t.expose("resource", {
        nullable: false,
        type: "Resource",
      }),
    }),
  }
);

How would I write this mutation using the effect plugin?

@iamchanii
Copy link
Owner

I think I should implement new builder method for integration for relay plugin. At this time, I'm sorry about you can't do it. If you provide a reproducible repository, I would check it soon as faster.

@iamchanii iamchanii added enhancement New feature or request good first issue Good for newcomers labels Jul 17, 2023
@vecerek
Copy link
Contributor Author

vecerek commented Jul 17, 2023

Hey @iamchanii, I've just created the following repository for you: vecerek/pothos-plugin-effect-example. I've documented:

  • how to run the server
  • what example mutation you can run to get both a success and a failure
  • how to re-generate the graphql schema file for comparison purposes to make sure the effect integration doesn't break it

If you have troubles running the project or anything else, just let me know 馃檪

@vecerek
Copy link
Contributor Author

vecerek commented Aug 1, 2023

@iamchanii so I asked about this to learn more about the recommended ways of going about the problem. I've learned that using relayMutationField isn't really recommended, so I'll look into implementing mutations using the regular APIs, though which I think I should have access to the effect fields. I'll report back on how it went and will close the issue depending on the results.

iamchanii added a commit that referenced this issue Aug 6, 2023
Got some questions about how to integrate the effect and relay plugins.
Getting connections working with more complex field builders is a bit
more involved, and requires the other plugin to specifically build out a
connection method (you can work around it, but its a lot easier if the
plugin supports it directly).

The strategies for interoperability are not really documented, and not
at all obvious, so I wanted to open this PR as a starting place for
supporting connections in the effect plugin

related to #3
@iamchanii
Copy link
Owner

Hey, @vecerek . I just release 0.7.0, so you can test t.effectConnection method from now. let me know it is enough for your purpose and feel free close issuse if you want.

https://github.com/iamchanii/pothos-plugin-effect/releases/tag/0.7.0

And thank you for your contribution and interest. this release wouldn't have been possible without your interest.

@iamchanii
Copy link
Owner

Note; From 1.0, t.effectConnection API will be remove. just use t.effect with resolve*Connection API from @pothos/plugin-relay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants