Skip to content

Latest commit

 

History

History
564 lines (495 loc) · 16.5 KB

api-reference.md

File metadata and controls

564 lines (495 loc) · 16.5 KB

AEM HEADLESS SDK API Reference

Classes

AEMHeadless

This class provides methods to call AEM GraphQL APIs. Before calling any method initialize the instance with GraphQL endpoint, GraphQL serviceURL and auth if needed

Typedefs

Model : object

GraphQL Model type

ModelResult : object
ModelResults : object
ModelEdge : object
PageInfo : object
ModelConnection : object
ModelByPathArgs : object
ModelListArgs : object
ModelPaginatedArgs : object
ModelArgs : ModelByPathArgs | ModelListArgs | ModelPaginatedArgs
QueryBuilderResult : object
ModelConfig : object

AEMHeadless

This class provides methods to call AEM GraphQL APIs. Before calling any method initialize the instance with GraphQL endpoint, GraphQL serviceURL and auth if needed

Kind: global class

new AEMHeadless(config)

Constructor.

If param is a string, it's treated as AEM server URL, default GraphQL endpoint is used. For granular params, use config object

ParamTypeDescription
configstring | object

Configuration object, or AEM server URL string

[config.serviceURL]string

AEM server URL

[config.endpoint]string

GraphQL endpoint

[config.auth]string | Array

Bearer token string or [user,pass] pair array

[config.headers]object

header { name: value, name: value, ... }

[config.fetch]object

custom Fetch instance

aemHeadless.runQuery(body, [options], [retryOptions]) ⇒ Promise.<any>

Returns a Promise that resolves with a POST request JSON data.

Kind: instance method of AEMHeadless
Returns: Promise.<any> - - the response body wrapped inside a Promise

ParamTypeDefaultDescription
bodystring | object

the query string or an object with query (and optionally variables) as a property

[options]object{}

additional POST request options

[retryOptions]object{}

retry options for @adobe/aio-lib-core-networking

aemHeadless.persistQuery(query, path, [options], [retryOptions]) ⇒ Promise.<any>

Returns a Promise that resolves with a PUT request JSON data.

Kind: instance method of AEMHeadless
Returns: Promise.<any> - - the response body wrapped inside a Promise

ParamTypeDefaultDescription
querystring

the query string

pathstring

AEM path to save query, format: configuration_name/endpoint_name

[options]object{}

additional PUT request options

[retryOptions]object{}

retry options for @adobe/aio-lib-core-networking

aemHeadless.listPersistedQueries([options], [retryOptions]) ⇒ Promise.<any>

Returns a Promise that resolves with a GET request JSON data.

Kind: instance method of AEMHeadless
Returns: Promise.<any> - - the response body wrapped inside a Promise

ParamTypeDefaultDescription
[options]object{}

additional GET request options

[retryOptions]object{}

retry options for @adobe/aio-lib-core-networking

aemHeadless.runPersistedQuery(path, [variables], [options], [retryOptions]) ⇒ Promise.<any>

Returns a Promise that resolves with a GET request JSON data.

Kind: instance method of AEMHeadless
Returns: Promise.<any> - - the response body wrapped inside a Promise

ParamTypeDefaultDescription
pathstring

AEM path for persisted query, format: configuration_name/endpoint_name

[variables]object{}

query variables

[options]object{}

additional GET request options

[retryOptions]object{}

retry options for @adobe/aio-lib-core-networking

aemHeadless.runPaginatedQuery(model, fields, [config], [args], [options], [retryOptions])

Returns a Generator Function.

Kind: instance method of AEMHeadless

ParamTypeDefaultDescription
modelstring

contentFragment model name

fieldsstring

The query string for item fields

[config]ModelConfig{}

Pagination config

[args]ModelArgs{}

Query arguments

[options]object{}

additional POST request options

[retryOptions]object{}

retry options for @adobe/aio-lib-core-networking

aemHeadless.buildQuery(model, fields, [config], [args]) ⇒ QueryBuilderResult

Builds a GraphQL query string for the given parameters.

Kind: instance method of AEMHeadless
Returns: QueryBuilderResult - - object with The GraphQL query string and type

ParamTypeDefaultDescription
modelstring

contentFragment Model Name

fieldsstring

The query string for item fields

[config]ModelConfig{}

Pagination config

[args]ModelArgs{}

Query arguments

Model : object

GraphQL Model type

Kind: global typedef
Properties

NameTypeDescription
*any

model properties

ModelResult : object

Kind: global typedef
Properties

NameTypeDescription
itemModel

response item

ModelResults : object

Kind: global typedef
Properties

NameTypeDescription
itemsArray.<Model>

response items

ModelEdge : object

Kind: global typedef
Properties

NameTypeDescription
cursorstring

item cursor

nodeModel

item node

PageInfo : object

Kind: global typedef
Properties

NameTypeDescription
endCursorstring

endCursor

hasNextPageboolean

hasNextPage

hasPreviousPageboolean

hasPreviousPage

startCursorstring

startCursor

ModelConnection : object

Kind: global typedef
Properties

NameTypeDescription
edgesArray.<ModelEdge>

edges

pageInfoPageInfo

pageInfo

ModelByPathArgs : object

Kind: global typedef
Properties

NameTypeDescription
_pathstring

contentFragment path

variationstring

contentFragment variation

ModelListArgs : object

Kind: global typedef
Properties

NameTypeDescription
[_locale]string

contentFragment locale

[variation]string

contentFragment variation

[filter]object

list filter options

[sort]string

list sort options

[offset]number

list offset

[limit]number

list limit

ModelPaginatedArgs : object

Kind: global typedef
Properties

NameTypeDescription
[_locale]string

contentFragment locale

[variation]string

contentFragment variation

[filter]object

list filter options

[sort]string

list sort options

[first]number

number of list items

[after]string

list starting cursor

Kind: global typedef
Properties

NameTypeDescription
*any

placeholder property

QueryBuilderResult : object

Kind: global typedef
Properties

NameTypeDescription
typestring

Query type

queryQueryString

Query string

ModelConfig : object

Kind: global typedef
Properties

NameTypeDefaultDescription
[pageSize]number10

page size

[after]string | number

starting cursor or offset

[useLimitOffset]booleanfalse

use offset pagination