graphql-url

A url scalar for graphql

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
graphql-url
502.0.54 years ago6 years agoMinified + gzip package size for graphql-url in KB

Readme

graphql-url
graphql scalar validating that it's a correct url

Installation

yarn install graphql-url [--dev]

Usage

This module exports 3 different scalars - one for absolute urls (GraphQLAbsoluteUrl), one for relative urls (GraphQLRelativeUrl) and one for either relative or absolute urls (GraphQLUrl);
import { GraphQLUrl } from 'graphql-url';

const schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      foo: {
        type: GraphQLUrl,
        resolve() {
          return 'https://foo.com/bar';
        }
      }
    }
  })
});