graphql-api-0.2.0: Sketch of GraphQL stuff

Safe HaskellNone
LanguageHaskell2010

GraphQL.Internal.Name

Contents

Description

Representation of GraphQL names.

Synopsis

Documentation

makeName :: Text -> Either NameError Name Source #

Create a Name.

Names must match the regex [_A-Za-z][_0-9A-Za-z]*. If the given text does not match, return Nothing.

>>> makeName "foo"
Right (Name {unName = "foo"})
>>> makeName "9-bar"
Left (NameError "9-bar")

nameFromSymbol :: forall n. KnownSymbol n => Either NameError Name Source #

Convert a type-level Symbol into a GraphQL Name.

Named things

class HasName a where Source #

Types that implement this have values with a single canonical name in a GraphQL schema.

e.g. a field foo(bar: Int32) would have the name "foo".

If a thing *might* have a name, or has a name that might not be valid, don't use this.

If a thing is aliased, then return the *original* name.

Minimal complete definition

getName

Methods

getName :: a -> Name Source #

Get the name of the object.

Unsafe functions

unsafeMakeName :: HasCallStack => Text -> Name Source #

Create a Name, panicking if the given text is invalid.

Prefer makeName to this in all cases.

>>> unsafeMakeName "foo"
Name {unName = "foo"}