Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
# ----- Input Types ----- input CreateProductInput { name: String! price: Float! description: String categoryId: ID! tags: [String!] } input UpdateProductInput { name: String price: Float description: String tags: [String!] } type Mutation { createProduct(input: CreateProductInput!): Product! updateProduct(id: ID!, input: UpdateProductInput!): Product! deleteProduct(id: ID!): Boolean! } # ----- Custom Scalars ----- scalar Date scalar DateTime scalar EmailAddress scalar URL type User { id: ID! email: EmailAddress! avatar: URL createdAt: DateTime! birthDate: Date } # Resolver implementation (JavaScript): # import { GraphQLScalarType, Kind } from 'graphql'; # # const DateScalar = new GraphQLScalarType({ # name: 'Date', # serialize(value) { return value.toISOString().split('T')[0]; }, # parseValue(value) { return new Date(value); }, # parseLiteral(ast) { # if (ast.kind === Kind.STRING) return new Date(ast.value); # return null; # }, # });
Result
Open