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.

complex object types which are both output and input

See original GitHub issue

currently I have this in my app:

@ObjectType()
export class OrganisationFeatures extends ConstructorAssigner {
  @Field() campaigns: boolean
  @Field() custom_email_sender_address: boolean
  @Field() OKTA_SAML: boolean
  @Field() search_analytics: boolean
  @Field() SCORM: boolean
  @Field() custom_font: boolean
}

@InputObjectType()
export class OrganisationFeaturesInput extends ConstructorAssigner {
  @InputField() campaigns: boolean
  @InputField() custom_email_sender_address: boolean
  @InputField() OKTA_SAML: boolean
  @InputField() search_analytics: boolean
  @InputField() SCORM: boolean
  @InputField() custom_font: boolean
}

I’d love to be able to define both at once doing:

@DuplexObjectType()  // using a special type I can register both at once
export class OrganisationFeatures extends ConstructorAssigner {
  @Field() campaigns: boolean
  @Field() custom_email_sender_address: boolean
  @Field() OKTA_SAML: boolean
  @Field() search_analytics: boolean
  @Field() SCORM: boolean
  @Field() custom_font: boolean
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pie6kcommented, Jun 4, 2018

Recursive field = User has Dog > Dog has owner User > owner User has Dog > Dog has owner user etc… Recursive = Circular and it’s not possible to reflect it in input field.

1reaction
pie6kcommented, Jun 4, 2018

Thanks for your PR.

I think that maybe another type may not be even needed. What about auto-converting it when @ObjectType is used as input type on the fly?

So we could do

@ObjectType()
export class FooType {
  @Field() bar: string;
}

and ten simply use it as argument type

@SchemaRoot()
export class FooType {
  @Mutation foo(input: FooType) bar: string;
}

That would feel more intuitive than having another type.

It would be good to check if given ObjectType is inputable eg. it does not have any recurrsive fields etc.

I’ll think about it as I don’t want to make typegql 'frameworkish`.

If that could be accomplished with reasonable api, then actually I stop seeing point of even having InputType at all. We could just validate types of arguments for if they’re able to be input.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complex Input/Output Data - Micro Focus
Java Explorer supports complex data types such as arrays and objects as both input data and output data. The Output Value Wizard assists...
Read more >
Can you make a graphql type both an input and output type?
For this reason, input objects have a separate type in the system. An Input Object defines a set of input fields; the input...
Read more >
Mutations and Input Types - GraphQL
Input types can't have fields that are other objects, only basic scalar types, list types, and other input types. Naming input types with...
Read more >
How Computers Work: Input and Output
Input and output may sometimes be separated by time or distance or both. Here are some examples: Factory workers input data by punching...
Read more >
Input and Output - Computer Terminology
Input and Output Devices ... Before a computer can process your data, you need some method to input the data into the machine....
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