Skip to content

Custom scalars and types on the client (Typescript) #9370

Answered by eddeee888
craigrushforth asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @craigrushforth 👋

scalars option only changes the type of a Scalar but not the implementation, which seems to be what you are looking for.

You GraphQL client may have ways to change a scalar value to match the type. For example, Apollo Client allows changing an object's field behaviour in the fetched data: https://www.apollographql.com/docs/react/caching/cache-field-behavior/
(I'm unclear if it can target all Scalars? 🤔 )

For example, if you were using Apollo Client, you may have to add it into InMemoryCache like this:

const cache = new InMemoryCache({
  typePolicies: {
    Holding: { // Object type name
      fields: {
        marketValue: { // Field name
          read(value) { // `v…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@craigrushforth
Comment options

@maxcan
Comment options

@craigrushforth
Comment options

Answer selected by craigrushforth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants