@apollo-elements/lib

Library functions for apollo-elements

Usage no npm install needed!

<script type="module">
  import apolloElementsLib from 'https://cdn.skypack.dev/@apollo-elements/lib';
</script>

README

@apollo-elements/lib

Published on npm ISC License Release

Helper functions for Apollo Elements

🔎 Read the Full API Docs 🔎

createApolloClient

Creates a simple ApolloClient instance given a URI and some params.

createApolloClient({
  uri: '/graphql',
  typePolicies: {
    User: {
      fields: {
        fullName(_, { readField }) {
          return `${readField('firstName')} ${readField('lastName')}`;
        }
      }
    }
  }
});

hasAllVariables

Predicate that validates a GraphQL request (a DocumentNode and a variables object) as having all of its required (i.e. non-nullable) variables defined.

function hasAllVariables(params: { query: DocumentNode, variables: any }): boolean

isClientOperation

Predicate that validates a DocumentNode as being an exclusively client-side operation, i.e. all of it's requests are modified by a @client directive.

function isClientOperation(operation: Operation): boolean

isValidGql

Predicate that validates an object as a DocumentNode.

function isValidGql(document: DocumentNode | any): boolean