Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

graphql-type-lowercase-string

cjjenkinsomn13MIT0.2.0

Lowercase string scalar type for GraphQL.js

graphql, lowercase string, graphql scalar, scalar, string

readme

Travis Codecov

graphql-type-lowercase-string npm

LowercaseString scalar type for GraphQL.js.

Usage

This package exports a LowercaseString scalar GraphQL.js type which is useful for ensuring a field has no uppercase characters e.g a username.

import GraphQLLowercaseString from 'graphql-type-lowercase-string';

Programmatically-constructed schemas

The type can be used in a programmatically constructed schema:

import { GraphQLObjectType } from 'graphql';
import GraphQLLowercaseString from 'graphql-type-lowercase-string';

export default new GraphQLObjectType({
  name: 'MyType',
  fields: {
    myField: { type: GraphQLLowercaseString },
  },
});

SDL with graphql-tools

When using the SDL with graphql-tools, define GraphQLLowercaseString as the resolver for the corresponding scalar type in the schema:

import { makeExecutableSchema } from 'graphql-tools';
import GraphQLLowercaseString from 'graphql-type-lowercase-string';

const typeDefs = `
scalar LowercaseString

type MyType {
  myField: LowercaseString
}
`;

const resolvers = {
  LowercaseString: GraphQLLowercaseString,
};

export default makeExecutableSchema({ typeDefs, resolvers });

This project was inspired by graphql-type-json

changelog

Changelog

All changes to this project will be documented here