GithubHelp home page GithubHelp logo

Comments (6)

akomm avatar akomm commented on May 28, 2024 2

My relay mutation config looks like that:

saveProject:
  builder: 'Mutation'
  builderConfig:
    name: 'SaveProject'

saveWorkflow:
  builder: 'Mutation'
  builderConfig:
    name: 'SaveWorkflow'

With this You would only have to write this:

saveProject:
  type: 'Mutation'
  name: 'SaveProject'

saveWorkflow:
  type: 'Mutation'
  name: 'SaveWorkflow'

The implementation is domain specific though. I did not force it to be super generic. Still, you might want to use the idea to somehow make a generic solution out of it. If you want I can post you some code. But it also includes mapping arguments to DTOs (data transfer objects) which are automatically validated when you attach constraints on them (annotation). It also include some generic resolver that then redirects to a specific mutations handler.

Basically: following relay convention, you only need

  1. a name for the mutation and
  2. a field name

Out of this information you can imply the requirement for a 'SaveWorkflowInput' and 'SaveWorkflowPayload' type. You can define them as types separately. You have to, because that is the app specific part a generic solution can not imply for you.

from graphqlbundle.

ooflorent avatar ooflorent commented on May 28, 2024 2

Using graphql syntax would be better.

from graphqlbundle.

mcg-web avatar mcg-web commented on May 28, 2024

The GraphQL Relay Mutation js implementation look like returning a simple Field definition. So why not directly use Mutation Field builder with some config?

Mutation:
  type: object
  config:
    fields:
      introduceShip: 
        builder: Mutation
        builderConfig:
          inputFields: # Define the input
            shipName: {type: String!}
            factionId: {type: ID!} 
          outputFields: # Define the payload
            ship: {type: Ship}
            faction: {type: Faction}
          mutateAndGetPayload: "@=mutation('my_mutator', [value])"    

from graphqlbundle.

ooflorent avatar ooflorent commented on May 28, 2024

I don't like what you're proposing. If Mutation has a lot of mutation fields, then it's not possible to split then into multiple files.

from graphqlbundle.

mcg-web avatar mcg-web commented on May 28, 2024

OK I understand the need. That also mean that we can now define custom field definition separated from system types, so it become reusable. We can generalize this to all field builder...

from graphqlbundle.

akomm avatar akomm commented on May 28, 2024

Yes. With the new feature recently added! :)

from graphqlbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.