Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Components

Utility components that help you factor your graphql-based app.

npm i -S @apollo-elements/components
yarn add @apollo-elements/components
pnpm add @apollo-elements/components

<apollo-client uri="/graphql">
  <apollo-query>
    <script type="application/graphql" src="QuoteQuery.graphql"></script>
    <script type="application/json">
      { "name": "Neil Armstrong" }
    </script>
    <template>
      <figure ?hidden="{{ !data }}">
        <blockquote>{{ data.quote }}</blockquote>
        <figcaption>—{{ data.name }}</figcaption>
      </figure>
    </template>
  </apollo-query>

  <apollo-subscription>
    <script type="application/graphql" src="TMinus.subscription.graphql"></script>
    <template>
      <p ?hidden="{{ !data }}">
        T-Minus <time datetime="{{ data.datetime }}">{{ data.countdown }}</time>
      </p>
    </template>
  </apollo-subscription>

  <apollo-mutation data-type="Quote">
    <script type="application/graphql" src="QuoteMutation.graphql"></script>

    <label for="name">Name</label>
    <label for="comment">Comment</label>

    <input id="name" data-variable="name" value="Neil"/>
    <textarea id="comment" data-variable="quote" value="That's one small step..."></textarea>

    <button trigger>OK</button>
  </apollo-mutation>
</apollo-client>