90.0.0 • Published 1 month ago

@zimbra/api-client v90.0.0

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
1 month ago

CircleCI NPM Downloads NPM Version

@zimbra/api-client

A GraphQL client for making requests against the Zimbra SOAP API.

Install

npm install @zimbra/api-client

Features

Schema

A GraphQL Schema that maps Zimbra SOAP resources to GraphQL types is a core tenant of Zimbra GraphQL. This schema includes many of the common resources used in Zimbra SOAP commands such as Search, or GetFolder.

Transparent Batching

Zimbra GraphQL batches requests by default. Using two complementary techniques, Query Batching and DataLoader, batching happens automatically and is transparent to the API consumer. When combining this with Apollo's cache, this results in the minimal number of requests and very high network performance.

Apollo Utilities

Zimbra GraphQL exposes utilities for use with Apollo so that it's a breeze to connect an application to Zimbra GraphQL.

Normalization and Attribute Mapping

Many of the attributes in Zimbra SOAP are tersely named. Zimbra GraphQL includes a minimal normalization layer that (a) renames some keys for more clarity, and (b) does some light lossless normalization for things like Booleans (which are strings in Zimbra SOAP).

Session Header Notification Support (Realtime Updates)

Change notifications via Session Headers keeps the client in sync with changes made elsewhere. This is fully supported. The initial implementation handles a few common resource changes and inserts them into the cache.

GraphiQL Support

When running the zm-x-web app, a GraphiQL server is exposed at /graphiql. This is incredibly powerful for exploring and debugging a schema. Documentation for queries, mutations, and fields all lives right within GraphiQL. This is powered internally by Zimbra GraphQL and Apollo. Visit /graphql and check it out!

TypeScript Support

Zimbra GraphQL is written in TypeScript and exposes types for the GraphQL queries and mutations. This is a powerful tool when used in application code. It enables type checking for the complex API data types used in Zimbra. In addition, it's completely transparent to use Zimbra GraphQL with plain JavaScript — you just lose the benefits of typed queries.

Better Error Handling

Batch and SOAP request Fault errors are now handled properly and exposed through GraphQL as you would expect.

Design Goals

A few design goals outline how Zimbra GraphQL works:

There should be minimal GraphQL abstraction over Zimbra SOAP resources

Long-term the schema is evolving towards GraphQL queries and mutations mapping roughly 1-to-1 to SOAP commands. It's up to the application code to provide abstraction over the data itself. This is for a few reasons:

Provide a straight forward way to add new functionality

Adding to the API is simplified and now involves only a few steps:

  • Ensure the types you need are in the schema
  • Design your query/mutation in application code
  • Add the associated simplified resolving function for your query/mutation to the resolvers
  • Add any attribute mapping needed to the entities declaration

Provide type safety if possible

Aforementioned, type safety is a powerful tool when combined with GraphQL.

Usage

With Apollo

import ApolloClient from 'apollo-client';
import { createZimbraSchema } from 'zimbra-graphql';
import { LocalBatchLink, ZimbraInMemoryCache } from 'zimbra-graphql/apollo';

// Create the Zimbra Apollo Cache
const cache = new ZimbraInMemoryCache();
// Pass a reference to the cache to the schema creation for session header (realtime) support
// Returns the schema and a reference to the underlying batch client
const { schema /*, client */ } = createZimbraSchema({ cache });
const link = new LocalBatchLink({ schema });
const apolloClient = new ApolloClient({ link, cache });
<ApolloProvider client={apolloClient}>/* children */</ApolloProvider>

Using the client directly

Under normal use with GraphQL, you should be using createZimbraSchema. However, you can also access the batch client directly.

import { ZimbraBatchClient } from 'zimbra-graphql/client';

const client = new ZimbraBatchClient();

// Use a top-level API method

client.search(searchOptions).then(response => {
	console.log(response);
});

// Or use `jsonRequest` directly

client
	.jsonRequest({
		name: 'GetInfo',
		namespace: Namespace.Account
	})
	.then(response => {
		console.log(response);
	});

In addition, the request primitives are also available:

import { jsonRequest, batchJsonRequest } from 'zimbra-graphql/request';

Provide Custom Fetch API

By default, ZimbraBatchClient uses fetch api of browser. In case, ZimbraBatchClient is used on non-browser platforms (i.e. NodeJS App), it will throw an error, such as: fetch is not defined.

In such case, customFetch option key allows to override or provide third-party fetch module/method.

const client = new ZimbraBatchClient({ customFetch: myCustomFetchMethod });

Hacking on the Client

See the wiki for details on how to add new APIs to the client.

90.0.0

1 month ago

89.0.0

4 months ago

87.1.0

8 months ago

88.0.0

6 months ago

86.1.0

11 months ago

87.0.0

8 months ago

86.0.0

11 months ago

85.0.0

1 year ago

85.0.1

12 months ago

85.0.3

12 months ago

84.0.0

1 year ago

79.0.0

2 years ago

80.1.0

2 years ago

80.0.0

2 years ago

74.0.0

2 years ago

81.0.0

2 years ago

69.0.2

2 years ago

69.0.1

2 years ago

77.0.0

2 years ago

78.0.0-beta

2 years ago

82.0.0

1 year ago

76.0.0

2 years ago

78.0.0

2 years ago

75.0.0

2 years ago

83.1.0

1 year ago

83.0.0

1 year ago

70.0.0

2 years ago

68.0.0

3 years ago

73.0.0

2 years ago

69.0.0

2 years ago

71.0.0

2 years ago

67.0.0

3 years ago

66.0.0

3 years ago

65.0.0

3 years ago

64.0.0

3 years ago

63.0.0

3 years ago

62.0.0

3 years ago

61.0.0

3 years ago

60.0.0

3 years ago

59.0.0

3 years ago

58.0.0

3 years ago

57.0.0

3 years ago

56.0.0

3 years ago

55.1.0

3 years ago

55.0.0

3 years ago

54.0.0

3 years ago

53.0.0

3 years ago

52.0.0

3 years ago

51.0.0

3 years ago

50.0.0

3 years ago

49.0.0

4 years ago

48.0.0

4 years ago

47.0.0

4 years ago

46.0.0

4 years ago

45.0.0

4 years ago

44.1.0

4 years ago

44.0.0

4 years ago

43.0.0

4 years ago

42.0.0

4 years ago

41.0.0

4 years ago

41.1.0

4 years ago

40.0.0

4 years ago

39.0.0

4 years ago

38.0.1

4 years ago

38.0.0

4 years ago

37.1.0

4 years ago

37.0.0

4 years ago

36.2.0

4 years ago

36.1.0

4 years ago

36.0.0

4 years ago

35.0.0

4 years ago

34.0.0

4 years ago

33.0.0

4 years ago

32.0.1

4 years ago

32.0.0

4 years ago

31.1.0

4 years ago

31.0.0

4 years ago

28.0.0

4 years ago

27.0.0

4 years ago

26.0.1

4 years ago

26.0.0

4 years ago

25.10.0

4 years ago

25.9.0

4 years ago

25.7.0-beta.1

4 years ago

25.8.0

4 years ago

25.7.0

4 years ago

25.6.2

4 years ago

25.6.1

5 years ago

25.6.0

5 years ago

25.5.0

5 years ago

25.4.0

5 years ago

25.3.0

5 years ago

25.2.0

5 years ago

25.1.0

5 years ago

25.0.0

5 years ago

24.0.0

5 years ago

23.6.0

5 years ago

23.5.0

5 years ago

23.4.0

5 years ago

23.3.0

5 years ago

23.2.0

5 years ago

23.1.0

5 years ago

23.0.0

5 years ago

22.0.0

5 years ago

21.7.0

5 years ago

21.6.0

5 years ago

21.5.0

5 years ago

21.4.0

5 years ago

21.3.0

5 years ago

21.2.0

5 years ago

21.1.0

5 years ago

21.0.0

5 years ago

20.4.0

5 years ago

20.3.0

5 years ago

20.2.0

5 years ago

20.1.0

5 years ago

20.0.0

5 years ago

19.5.0

5 years ago

19.4.0

5 years ago

19.3.0

5 years ago

19.2.0

5 years ago

19.1.0

5 years ago

19.0.4

5 years ago

19.0.3

5 years ago

19.0.2

5 years ago

19.0.1

5 years ago

19.0.0

5 years ago

18.0.0

5 years ago

17.2.0

5 years ago

17.1.0

5 years ago

17.0.0

5 years ago

16.6.0

5 years ago

16.5.0

5 years ago

16.4.0

5 years ago

16.3.0

5 years ago

16.2.0

5 years ago

16.1.0

5 years ago

16.0.0

5 years ago

16.0.0-beta.7

5 years ago

16.0.0-beta.6

5 years ago

16.0.0-beta.5

5 years ago

16.0.0-beta.4

5 years ago

16.0.0-beta.3

5 years ago

16.0.0-beta.2

5 years ago

16.0.0-beta.1

5 years ago

15.0.0

5 years ago

14.0.0-beta.5

5 years ago

14.0.0-beta.4

5 years ago

14.0.0-beta.3

5 years ago

14.0.0-beta.2

5 years ago

14.0.0-beta.1

5 years ago

13.0.0

5 years ago

13.0.0-beta.17

5 years ago

13.0.0-beta.16

5 years ago

13.0.0-beta.15

5 years ago

13.0.0-beta.14

5 years ago

13.0.0-beta.13

5 years ago

13.0.0-beta.12

5 years ago

13.0.0-beta.11

5 years ago

13.0.0-beta.9

5 years ago

13.0.0-beta.8

5 years ago

13.0.0-beta.7

5 years ago

13.0.0-beta.6

5 years ago

13.0.0-beta.5

5 years ago

13.0.0-beta.4

5 years ago

13.0.0-beta.3

5 years ago

13.0.0-beta.2

5 years ago

13.0.0-beta.1

5 years ago

12.0.0

5 years ago

12.0.0-beta.8

5 years ago

12.0.0-beta.7

5 years ago

12.0.0-beta.6

5 years ago

12.0.0-beta.5

5 years ago

12.0.0-beta.4

5 years ago

12.0.0-beta.3

5 years ago

12.0.0-beta.2

5 years ago

12.0.0-beta.1

5 years ago

11.0.0

5 years ago

10.0.0-beta.5

5 years ago

10.0.0-beta.4

5 years ago

10.0.0-beta.3

5 years ago

10.0.0-beta.2

5 years ago

10.0.0-beta.1

5 years ago

9.0.0

5 years ago

9.0.0-beta.16

5 years ago

9.0.0-beta.15

5 years ago

9.0.0-beta.14

5 years ago

9.0.0-beta.13

5 years ago

9.0.0-beta.12

5 years ago

9.0.0-beta.11

5 years ago

9.0.0-beta.10

6 years ago

9.0.0-beta.9

6 years ago

9.0.0-beta.8

6 years ago

9.0.0-beta.7

6 years ago

9.0.0-beta.6

6 years ago

9.0.0-beta.5

6 years ago

9.0.0-beta.4

6 years ago

9.0.0-beta.3

6 years ago

9.0.0-beta.2

6 years ago

9.0.0-beta.1

6 years ago

8.2.0

6 years ago

8.1.0

6 years ago

8.0.0

6 years ago

7.3.0

6 years ago

7.2.0

6 years ago

7.1.0

6 years ago

7.0.0

6 years ago

6.6.0

6 years ago

6.5.0

6 years ago

6.4.0

6 years ago

6.3.0

6 years ago

6.2.0

6 years ago

6.1.0

6 years ago

6.0.0

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.5.0

6 years ago

4.4.0

6 years ago

4.3.0

6 years ago

4.2.0

6 years ago

4.1.0

6 years ago

4.0.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.6

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago