How to use the GraphQLScalarType function from graphql
Find comprehensive JavaScript graphql.GraphQLScalarType code examples handpicked from public code repositorys.
12 13 14 15 16 17 18 19 20 21 22ASC: { value: 'ASC' }, DESC: { value: 'DESC' } } }) const limitType = new graphql.GraphQLScalarType({ name: 'LimitInt', description: 'Limit will be applied by default if not passed. If the provided value exceeds the maximum allowed value a validation error will be thrown' })
+ 32 other calls in file
1 2 3 4 5 6 7 8 9 10const assert = require('assert'); const _ = require('lodash'); const InputObjectType = graphql.GraphQLInputObjectType; const InterfaceType = graphql.GraphQLInterfaceType; const ScalarType = graphql.GraphQLScalarType; const ObjectType = graphql.GraphQLObjectType; const UnionType = graphql.GraphQLUnionType; const NonNullType = graphql.GraphQLNonNull; const EnumType = graphql.GraphQLEnumType;
+ 3 other calls in file
36 37 38 39 40 41 42 43 44}); test("prints type relations", () => { expect.hasAssertions(); const type = new GraphQLScalarType({ name: "String", description: "Lorem Ipsum", });
+ 214 other calls in file
100 101 102 103 104 105 106 107 108}); test("returns empty string if not enum type", () => { expect.hasAssertions(); const scalarType = new GraphQLScalarType({ name: "ScalarTypeName", type: GraphQLInt, });
62 63 64 65 66 67 68 69 70 71|| isNonNullType(type) ); } function isScalarType(type) { return type instanceof gql.GraphQLScalarType; } function isObjectType(type) { return type instanceof gql.GraphQLObjectType; }
+ 9 other calls in file
41 42 43 44 45 46 47 48 49 50//Below function is a GraphQL scalar that defines a valid Date. //Serialize is used to send back/return a date in string format. //ParseValue is used to convert all input values that are provided as an input JS variable. //ParseLiteral is used to convert all input values that are in Int, String, etc. to a JSON-like form that GraphQL understands. */ const GraphQLDate = new GraphQLScalarType({ name: 'GraphQLDate', description: 'A Date() type in GraphQL as a scalar', serialize(value) { return value.toISOString();
+ 16 other calls in file
GitHub: drewpager/platos-peach
26 27 28 29 30 31 32 33 34 35description: "A valid date object", serialize: validate, parseValue: validate, parseLiteral, }; const GraphQLDate = new graphql_1.GraphQLScalarType(GraphQLDateConfig); const verifyCreateLessonInput = ({ title, category, meta, video, startDate, endDate, }) => { if (title.length > 160) { throw new Error("Title must not exceed 160 characters in length!"); }
+ 24 other calls in file
GitHub: mrpatrick2407/MERN
12 13 14 15 16 17 18 19 20 21 22 23 24]; //resolvers const GraphQLDate=new GraphQLScalarType({name:'GraphqlDate',description:'To retrieve the date in string format i serialize it',serialize(val){return val.toISOString();}, parseValue(value) { const dateValue = new Date(value); return isNaN(dateValue) ? undefined : dateValue; }, parseLiteral(ast) { if (ast.kind == Kind.STRING) { const value = new Date(ast.value); return isNaN(value) ? undefined : value; }
+ 96 other calls in file
45 46 47 48 49 50type: 'string', pattern: regexp.source, }, }, }; exports.GraphQLAccountNumber = new graphql_1.GraphQLScalarType(exports.GraphQLAccountNumberConfig);
+ 24 other calls in file
29 30 31 32 33 34 35 36 37 38} : undefined); } } }; exports.GraphQLTimeZone = new graphql_1.GraphQLScalarType({ name: 'TimeZone', description: 'A field whose value exists in the standard IANA Time Zone Database: https://www.iana.org/time-zones', serialize: validateTimeZone, parseValue: validateTimeZone,
+ 24 other calls in file
25 26 27 28 29 30 31 32 33 34if (!isCalendarDate) { throw (0, error_js_1.createGraphQLError)(`Value is not a valid LocalDate: ${value}`, ast ? { nodes: ast } : undefined); } return value; } exports.GraphQLLocalDate = new graphql_1.GraphQLScalarType({ name: 'LocalDate', description: 'A local date string (i.e., with no associated timezone) in `YYYY-MM-DD` format, e.g. `2020-01-01`.', serialize(value) { // value sent to client as string
+ 17 other calls in file
GitHub: saumyatalwani/blogBack
72 73 74 75 76 77type: 'string', format: 'byte', }, }, }; exports.GraphQLByte = new graphql_1.GraphQLScalarType(exports.GraphQLByteConfig);
+ 17 other calls in file
791 792 793 794 795 796 797 798 799 800{"username": args["username"]}, {$set: {"admin": args["isAdmin"]}} ); } }, StringOrFloat: new GraphQLScalarType({ name: "StringOrFloat", description: "A String or a Float union type", serialize(value) { if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
+ 38 other calls in file
36 37 38 39 40 41 42 43 44 45 46setGreetingMessage(message: String!): String employeeAdd(employee: employeeInputs!): Employee! } `; // const dateScalar = new GraphQLScalarType({ // name: "Date", // description: "Date custom scalar type", // serialize(value) { // return value.toISOString().substring(0, 10); // Convert outgoing Date to integer for JSON
+ 62 other calls in file
35 36 37 38 39 40 41 42 43 44const { GraphQLScalarType } = require("graphql"); const path = __importStar(require("path")); const fs = __importStar(require("fs")); const { fileRenamer } = require("../utils/helpers"); const resolvers = { Date: new GraphQLScalarType({ name: "Date", description: "Date custom scalar type", serialize(value) { return value.toISOString().slice(0, 10);
+ 10 other calls in file
GitHub: saumyatalwani/blogBack
11 12 13 14 15 16 17 18 19 20if (!IPv4_js_1.IPV4_REGEX.test(value) && !IPv6_js_1.IPV6_REGEX.test(value)) { throw (0, error_js_1.createGraphQLError)(`Value is not a valid IPv4 or IPv6 address: ${value}`, ast ? { nodes: ast } : undefined); } return value; }; exports.GraphQLIP = new graphql_1.GraphQLScalarType({ name: `IP`, description: `A field whose value is either an IPv4 or IPv6 address: https://en.wikipedia.org/wiki/IP_address.`, serialize(value) { return validate(value);
+ 12 other calls in file
GitHub: saumyatalwani/blogBack
10 11 12 13 14 15 16 17 18 19if (!exports.IPV6_REGEX.test(value)) { throw (0, error_js_1.createGraphQLError)(`Value is not a valid IPv6 address: ${value}`, ast ? { nodes: ast } : undefined); } return value; }; exports.GraphQLIPv6 = new graphql_1.GraphQLScalarType({ name: `IPv6`, description: `A field whose value is a IPv6 address: https://en.wikipedia.org/wiki/IPv6.`, serialize(value) { return validate(value);
+ 3 other calls in file
281 282 283 284 285 286 287 288 289 290variableDefinitions, argumentNodes }; } const rawField = 'raw'; const RawScalar = new graphql.GraphQLScalarType({ name: 'RawThingPlsDontRelyOnThisAnywhere' }); const ReturnRawValueObjectType = new graphql.GraphQLObjectType({ name: 'ReturnRawValue',
+ 8 other calls in file
graphql.GraphQLNonNull is the most popular function in graphql (4226 examples)

