graphql-scalars | custom GraphQL scalar types for creating precise type | GraphQL library
kandi X-RAY | graphql-scalars Summary
kandi X-RAY | graphql-scalars Summary
A library of custom GraphQL scalar types for creating precise type-safe GraphQL schemas, with validation powered by Yup.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of graphql-scalars
graphql-scalars Key Features
graphql-scalars Examples and Code Snippets
Community Discussions
Trending Discussions on graphql-scalars
QUESTION
I am trying to follow the documentation on the Nexus-Schema (nexusjs) website for adding scalar types to my GraphQL application.
I have tried adding many of the different implementations to my src/types/Types.ts
file using the samples provided in the documentation and the interactive examples. My attempts include:
Without a 3rd party libraries:
...ANSWER
Answered 2020-Dec-01 at 18:39The issue seems to be resolved when --transpile-only
flag is added to the nexus:reflect command.
This means the reflection command gets updated to:
QUESTION
I just made a simple Scalar type/package for Node, graphql-scalar-json5.
It seems to me to be working as expected
But I got a question about it
seems like using this bypasses type-checking as opposed to using an input type?
It got me thinking I might be doing something wrong.
While you get an error, at resolve time, if the value is Not valid.
There is no warning in GraphiQL
I'm not sure if this is limitation of custom scalar types in GraphQL. or a GraphiQL implementation detail
At 1st impression it makes sense, that if a JSON5 (or JSON) value is effectively deriving from the String type, but I never told 'GraphQL' about it, and doesn't seem to be way to do so ...
How will the tool know the parameter is of the wrong type?
Taking another custom scalar, EmailAddress, from graphql-scalars
With the following Query definition
...ANSWER
Answered 2020-Jul-01 at 13:17Custom type/scalar ... it should be obvious that you need custom validation.
on backend/API:Both parseValue
and parseLiteral
are quarded by MyScalar.from
.
Already "accepted" (validated 'on input') value usually doesn't need additional validation 'on output' (serialize
). It seams that you sometimes could use it to "correct" data/format/value but probably you would do it on resolver level (read DB - before returning data that should match type[-s]).
AFAIK There is no way to inform system how to validate your custom types/scalars - simply can't be supported.
on frontend:You have (should) to implement the same validation (equal to used on API/backend) rules before sending custom data (variables).
QUESTION
I'm using graphql-scalars in order to have BigInt type in my graphql schema. It runs but that BigInts have this format: {
"data": {
"createStage": "41"
}
} It is doublequoted so it is not an numeric type but an string. Am I doing something in bad way? Thanks
...ANSWER
Answered 2020-May-16 at 10:59This is intended behavior. The BigInt scalar can represent integers that are larger than what JavaScript supports (9007199254740991), so the value is always serialized as a string in the response.
QUESTION
ANSWER
Answered 2020-Apr-23 at 21:48"Date" and "DateTime" can be tricky. For example, is "15:00" 3:00pm Pacific Time?
Many (most) implementations resolve the problem by storing "datetime" as a large integer with respect to some "epoch". For example, "0" might represent "number of seconds since Jan 1, 1970".
Perhaps you might consider storing your GraphQL "DateTime" as an ISO 8601 string, or using this module: https://www.npmjs.com/package/graphql-iso-date
At the "schema" level (vs. JS code, as I suggested above), you might consider this:
3.5 Scalars:
Scalars ScalarTypeDefinition DescriptionoptscalarNameDirectivesConstopt Scalar types represent primitive leaf values in a GraphQL type system. GraphQL responses take the form of a hierarchical tree; the leaves on these trees are GraphQL scalars.
All GraphQL scalars are representable as strings, though depending on the response format being used, there may be a more appropriate primitive for the given scalar type, and server should use those types when appropriate.
GraphQL provides a number of built‐in scalars, but type systems can add additional scalars with semantic meaning. For example, a GraphQL system could define a scalar called Time which, while serialized as a string, promises to conform to ISO‐8601. When querying a field of type Time, you can then rely on the ability to parse the result with an ISO‐8601 parser and use a client‐specific primitive for time.
QUESTION
I'm new to Docker, and I've wanted try Dockerizing my node app.
I've tried following the directions on nodejs.org, but I've been getting errors on npm install
.
Here is my Dockerfile:
...ANSWER
Answered 2020-Feb-10 at 12:43I used to get this error due to low or intermittent internet bandwidth.
QUESTION
I'm learning how to use Apollo Client for React and how to manage local state using the cache. From the docs, it's as simple as writing to the cache using cache.writeData
and reading from it using a simple query. Their example is
ANSWER
Answered 2019-May-02 at 12:51From the docs:
[The @client directive] tells Apollo Client to fetch the field data locally (either from the cache or using a local resolver), instead of sending it to our GraphQL server.
If the directive is present on a field, Apollo will attempt to resolve the field using the provided resolver, or fall back to fetching directly from the cache if one doesn't exist. You can initialize your cache with pretty much any sort of data at the root level (taking care to include __typename
fields for objects) and you should be able to fetch it without having to also provide a resolver
for it. On the other hand, providing a resolver can provide you with more granular control over what's actually fetched from the cache -- i.e. you could initialize the cache with an array of items, but use a resolver to provide a way to filter or sort them.
There's an import nuance here: Fetching without a resolver only works when there's data in the cache to fetch. That's why it's important to provide initial state for these fields when building your client. If you have a more deeply nested @client
field (for example, maybe you're including additional information alongside data fetched from the server), you also technically don't have to write a resolver. But we typically do write them because there is no existing data in the cache for those nested fields.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install graphql-scalars
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page