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.

[client-preset] allowed options and defaults

See original GitHub issue

This issue is the place to discuss allowed options and default values when using the preset: 'client' setup.

Currently supported options

  • scalars
  • strictScalars
  • namingConvention
  • useTypeImports
  • skipTypename
  • enumsAsTypes
  • arrayInputCoercion
  • presetConfig.fragmentMasking
  • presetConfig.gqlTagName
  • presetConfig.unmaskFunctionName
  • emitLegacyCommonJSImports

Requested options support

Current defaults

  • presetConfig.fragmentMasking: true
  • inlineFragmentTypes: true (if fragment masking is enabled)
  • emitLegacyCommonJSImports: true

Requested defaults

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:17

github_iconTop GitHub Comments

2reactions
n1ru4lcommented, Nov 9, 2022

@ShravanSunder I agree with all your proposals - except maybeValue: 'T | undefined | null',. The maybe/value for nullable fields should be T | null - it can never be undefined.

2reactions
n1ru4lcommented, Nov 2, 2022

nonOptionalTypename is dangerous IMHO - It allows the wrong configuration.

E.g. the correct type for

query MeQuery {
  me {
    id
  }
}

is

type MeQuery = {
  me: {
    id: string
  }
}

not

type MeQuery = {
  me: {
    __typename?: "User",
    id: string
  }
}

or

type MeQuery = {
  me: {
    __typename: "User",
    id: string
  }
}

However, GraphQL clients such as apollo and urql ADD __typename selections to the documents before sending them to the GraphQL server. I am unsure whether I like this behavior. But if you look at this it makes sense why the defaults are like they are today.

Having that said, for me, the following makes the most sense:

  • __typename is OMITTED from the generated types by default.

Adding the __typename property to the generated type via a configuration option by default, either as optional or mandatory - is something I would ideally try to avoid - but I can also see why people don’t want to explicitly clutter their GraphQL Operation documents with __typename selections.

In order to make the apollo/urql users happy this means we will kind of need an automaticallyAddTypenameSelection configuration.

This is a potential proposal that groups the configuration under one object property:

type AutoTypenamesSelectionConfig = boolean | {
  skipRootTypes?: boolean
}

I don’t event think we need to allow adding __typename properties as optional - it should either be non-optional or not at all present.

Curious to hear the use-cases of having __typename?: "User".

Read more comments on GitHub >

github_iconTop Results From Across the Web

client-preset - GraphQL Code Generator
The client preset allows the following config options: scalars : Extends or overrides the built-in scalars and custom GraphQL scalars to a ...
Read more >
MacOS Client: change default ClientSettings ... - TechNet - Microsoft
in 10.3.3 user defaults were set to disable clipboard, mic, smartcard, camera, and folder redirection. Is it possible to change any of these...
Read more >
Core Model / Components - Spring
clientSettings : The custom settings for the client – for example, require PKCE, require authorization consent, and others. 12, tokenSettings : ...
Read more >
Configuring Client Settings
Configuring Client Settings. By default, all clients share the same configuration (default configuration according to Configuring LDAP Sync).
Read more >
Client Settings - Shrew Soft VPN Client Administrators Guide
The Firewall Options settings are used to define what features will be enabled to prevent problems from occurring when a Firewall or NAT...
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