question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic Relay InputType

See original GitHub issue

Is your feature request related to a problem? Please describe. If I want to write Mutations according to the relay guide I have to declare an input type containing all arguments and a clientMutationId which is returned in the response. Currently I have to write a lot of annoying Code. One class for the input, one for the payload and in the Mutation itself I have to pass the clientMutationId from the input to the payload manually.

Describe the solution you’d like I would like to have a very simple and easy solution to speed up development. Maybe something like:

In my mutation/Resolver i would like to have a function as always without the inputType:

public User CreateUser(string firstname, string lastname, CancellationToken ctx){
	...
	return new User(....);
}

in my ObjectType for the Muation I would like to do something like:

 descriptor
	.Field(m =>  m.CreateUser(default, default, default))
    .UseRelayInputType()

this than should convert this stuff to provide a schema like:

type Mutation {
	createUser(input: CreateUserInput!): CreateUserPayload!
}

type CreateUserInput{
	fistname: String
	lastname: String
	clientMutationId: String
}

type CreateUserPayload{
	user: User
	clientMutationId: String
}

HC should then automatically pass the `clientMutationId``from the input to the payload and all the fields should be mapped. The GraphQLNonNullType should be respected by this solution

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
tobias-tenglercommented, Apr 27, 2021

The clientMutationId is no longer apart of Relay. It was removed when Relay Modern was introduced (3 years ago). Reference. I’m not sure if this should or even needs to be covered by HC at this point!?

2reactions
RohrerFcommented, Apr 27, 2021

It would still be nice if HC would provide an easy way to convert from “normal” functions like

public User CreateUser(string firstname, string lastname, CancellationToken ctx){
	...
	return new User(....);
}

to GraphQL like mutations

type Mutation {
	createUser(input: CreateUserInput!): CreateUserPayload!
}

type CreateUserInput{
	fistname: String
	lastname: String
}

type CreateUserPayload{
	user: User
} 

(not sure if the payload part makes sense in this case but the input certainly would)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic Relay InputType · Issue #773 · ChilliCream ...
If I want to write Mutations according to the relay guide I have to declare an input type containing all arguments and a...
Read more >
Unable to generate auto generated files in relay compiler ...
I am trying to create a web application with ReactJs as frontend, GraphQL as service layer and Relay as communication between service layer...
Read more >
A deep-dive into Relay, the friendly & opinionated ...
A comprehensive guide to building performant, type-safe apps with Relay, from GraphQL fragments and query best practices, to the Relay ...
Read more >
An automatic configurable relay - CN103065870A
An automatic configurable relay and a method for automatic configuration of a relay are provided. The relay comprises an input sampling module for...
Read more >
Smart Relay Output - Ethernet IO
The Smart Relay Output is an Ethernet device with 8 Integrated controllable relays. The device allows for web based control of the relays...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found