Skip to content

Using GraphQL in Zimlets

Peter Lenahan edited this page Sep 4, 2019 · 5 revisions

To get started learning GraphQL queries, see Queries and Mutations | GraphQL.

See schema.graphql for a full list of fields that can be queried in the Zimbra schema.

Example

import gql from 'graphql-tag';
import { graphql } from 'react-apollo';

@graphql(gql`
  query GetPreferences {
    getPreferences {
      zimbraPrefLocale
    }
  }
`)
class MyClass extends Component {
  render({ data }) {
    const { loading, error, getPreferences } = data;
    return loading ? (
      'GetPreferences Loading...'
    ) : error ? (
      `GetPreferences ERROR: ${error}`
    ) : (
      <div>Some data from getPreferences: {getPreferences.zimbraPrefLocale}
    );
  }
}

Related Libraries

GraphiQL

GraphiQL is "A graphical interactive in-browser GraphQL IDE", useful for testing queries and getting an instant response.

See the /graphiql route of the Zimbra X Client for a GraphiQL instance to query the current GraphQL schema.

Clone this wiki locally