graphql-relay
- Version 0.10.2
- Published
- 45.6 kB
- No dependencies
- MIT license
Install
npm i graphql-relayyarn add graphql-relaypnpm add graphql-relayOverview
A library to help construct a graphql-js server supporting react-relay.
Index
Variables
Functions
- connectionDefinitions()
- connectionFromArray()
- connectionFromArraySlice()
- connectionFromPromisedArray()
- connectionFromPromisedArraySlice()
- cursorForObjectInConnection()
- cursorToOffset()
- fromGlobalId()
- getOffsetWithDefault()
- globalIdField()
- mutationWithClientMutationId()
- nodeDefinitions()
- offsetToCursor()
- pluralIdentifyingRootField()
- toGlobalId()
Interfaces
Type Aliases
Variables
variable backwardConnectionArgs
const backwardConnectionArgs: GraphQLFieldConfigArgumentMap;Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field whose return type is a connection type with backward pagination.
variable connectionArgs
const connectionArgs: GraphQLFieldConfigArgumentMap;Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field whose return type is a connection type with bidirectional pagination.
variable forwardConnectionArgs
const forwardConnectionArgs: GraphQLFieldConfigArgumentMap;Returns a GraphQLFieldConfigArgumentMap appropriate to include on a field whose return type is a connection type with forward pagination.
Functions
function connectionDefinitions
connectionDefinitions: ( config: ConnectionConfig) => GraphQLConnectionDefinitions;Returns a GraphQLObjectType for a connection with the given name, and whose nodes are of the specified type.
function connectionFromArray
connectionFromArray: <T>( data: ReadonlyArray<T>, args: ConnectionArguments) => Connection<T>;A simple function that accepts an array and connection arguments, and returns a connection object for use in GraphQL. It uses array offsets as pagination, so pagination will only work if the array is static.
function connectionFromArraySlice
connectionFromArraySlice: <T>( arraySlice: ReadonlyArray<T>, args: ConnectionArguments, meta: ArraySliceMetaInfo) => Connection<T>;Given a slice (subset) of an array, returns a connection object for use in GraphQL.
This function is similar to
connectionFromArray, but is intended for use cases where you know the cardinality of the connection, consider it too large to materialize the entire array, and instead wish pass in a slice of the total result large enough to cover the range specified inargs.
function connectionFromPromisedArray
connectionFromPromisedArray: <T>( dataPromise: Promise<ReadonlyArray<T>>, args: ConnectionArguments) => Promise<Connection<T>>;A version of
connectionFromArraythat takes a promised array, and returns a promised connection.
function connectionFromPromisedArraySlice
connectionFromPromisedArraySlice: <T>( dataPromise: Promise<ReadonlyArray<T>>, args: ConnectionArguments, arrayInfo: ArraySliceMetaInfo) => Promise<Connection<T>>;A version of
connectionFromArraySlicethat takes a promised array slice, and returns a promised connection.
function cursorForObjectInConnection
cursorForObjectInConnection: <T>( data: ReadonlyArray<T>, object: T) => ConnectionCursor | null;Return the cursor associated with an object in an array.
function cursorToOffset
cursorToOffset: (cursor: ConnectionCursor) => number;Extracts the offset from the cursor string.
function fromGlobalId
fromGlobalId: (globalId: string) => ResolvedGlobalId;Takes the "global ID" created by toGlobalID, and returns the type name and ID used to create it.
function getOffsetWithDefault
getOffsetWithDefault: ( cursor: ConnectionCursor | null | undefined, defaultOffset: number) => number;Given an optional cursor and a default offset, returns the offset to use; if the cursor contains a valid offset, that will be used, otherwise it will be the default.
function globalIdField
globalIdField: <TContext>( typeName?: string, idFetcher?: ( obj: any, context: TContext, info: GraphQLResolveInfo ) => string | number) => GraphQLFieldConfig<any, TContext>;Creates the configuration for an id field on a node, using
toGlobalIdto construct the ID from the provided typename. The type-specific ID is fetched by calling idFetcher on the object, or if not provided, by accessing theidproperty on the object.
function mutationWithClientMutationId
mutationWithClientMutationId: <TInput = any, TOutput = unknown, TContext = any>( config: MutationConfig<TInput, TOutput, TContext>) => GraphQLFieldConfig<unknown, TContext>;Returns a GraphQLFieldConfig for the mutation described by the provided MutationConfig.
function nodeDefinitions
nodeDefinitions: <TContext>( fetchById: (id: string, context: TContext, info: GraphQLResolveInfo) => unknown, typeResolver?: GraphQLTypeResolver<any, TContext>) => GraphQLNodeDefinitions<TContext>;Given a function to map from an ID to an underlying object, and a function to map from an underlying object to the concrete GraphQLObjectType it corresponds to, constructs a
Nodeinterface that objects can implement, and a field config for anoderoot field.If the typeResolver is omitted, object resolution on the interface will be handled with the
isTypeOfmethod on object types, as with any GraphQL interface without a providedresolveTypemethod.
function offsetToCursor
offsetToCursor: (offset: number) => ConnectionCursor;Creates the cursor string from an offset.
function pluralIdentifyingRootField
pluralIdentifyingRootField: ( config: PluralIdentifyingRootFieldConfig) => GraphQLFieldConfig<unknown, unknown>;function toGlobalId
toGlobalId: (type: string, id: string | number) => string;Takes a type name and an ID specific to that type name, and returns a "global ID" that is unique among all types.
Interfaces
interface Connection
interface Connection<T> {}A type designed to be exposed as a
Connectionover GraphQL.
interface ConnectionArguments
interface ConnectionArguments {}A type describing the arguments a connection field receives in GraphQL.
interface ConnectionConfig
interface ConnectionConfig {}property connectionFields
connectionFields?: ThunkObjMap<GraphQLFieldConfig<any, any>>;property edgeFields
edgeFields?: ThunkObjMap<GraphQLFieldConfig<any, any>>;property name
name?: string;property nodeType
nodeType: GraphQLNamedOutputType | GraphQLNonNull<GraphQLNamedOutputType>;property resolveCursor
resolveCursor?: GraphQLFieldResolver<any, any>;property resolveNode
resolveNode?: GraphQLFieldResolver<any, any>;interface Edge
interface Edge<T> {}A type designed to be exposed as a
Edgeover GraphQL.
interface GraphQLConnectionDefinitions
interface GraphQLConnectionDefinitions {}property connectionType
connectionType: GraphQLObjectType;property edgeType
edgeType: GraphQLObjectType;interface PageInfo
interface PageInfo {}A type designed to be exposed as
PageInfoover GraphQL.
property endCursor
endCursor: ConnectionCursor | null;property hasNextPage
hasNextPage: boolean;property hasPreviousPage
hasPreviousPage: boolean;property startCursor
startCursor: ConnectionCursor | null;Type Aliases
type ConnectionCursor
type ConnectionCursor = string;A type alias for cursors in this implementation.
Package Files (6)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/graphql-relay.
- Markdown[](https://www.jsdocs.io/package/graphql-relay)
- HTML<a href="https://www.jsdocs.io/package/graphql-relay"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3134 ms. - Missing or incorrect documentation? Open an issue for this package.
