code: func NewScalar(config ScalarConfig) *Scalar {
  	st := &Scalar{}
  	err := invariant(config.Name != "", "Type must be named.")
  	if err != nil {
  		st.err = err
  		return st
  	}
  
  	err = assertValidName(config.Name)
  	if err != nil {
  		st.err = err
  		return st
  	}
  
  	st.PrivateName = config.Name
  	st.PrivateDescription = config.Description
  
  	err = invariantf(
  		config.Serialize != nil,
  		`%v must provide "serialize" function. If this custom Scalar is `+
  			`also used as an input type, ensure "parseValue" and "parseLiteral" `+
  			`functions are also provided.`, st,
  	)
  	if err != nil {
  		st.err = err
  		return st
  	}
  	if config.ParseValue != nil || config.ParseLiteral != nil {
  		err = invariantf(
  			config.ParseValue != nil && config.ParseLiteral != nil,
  			`%v must provide both "parseValue" and "parseLiteral" functions.`, st,
  		)
  		if err != nil {
  			st.err = err
  			return st
  		}
  	}
  
  	st.scalarConfig = config
  	return st
  }
docs: // NewScalar creates a new GraphQLScalar