How to use the apollo-utilities.getMainDefinition function in apollo-utilities

To help you get started, we’ve selected a few apollo-utilities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tengen-io / web-client / src / contexts / apolloContext.tsx View on Github external
const link = split(({query}) => {
      const { kind, operation } = getMainDefinition(query);
      return kind === 'OperationDefinition' && operation == 'subscription';
    }, wsLink, authLink.concat(httpLink));
github mrdulin / angular-apollo-starter / src / app / graphql / graphql.module.ts View on Github external
({ query }) => {
        const { kind, operation } = getMainDefinition(
          query
        ) as OperationDefinitionNode;
        return kind === 'OperationDefinition' && operation === 'subscription';
      },
      wsLink,
github ilyaskarim / apollo-graphql-chat / client / src / Apollo.js View on Github external
({ query }) => {
    const { kind, operation } = getMainDefinition(query);
    return kind === 'OperationDefinition' && operation === 'subscription';
  },
  wsLink,
github expo / pound-random / pound-random-app / App.js View on Github external
({ query }) => {
    const { kind, operation } = getMainDefinition(query);
    return kind === 'OperationDefinition' && operation === 'subscription';
  },
  wsLink,
github DCtheTall / node-video-chat / src / client / index.jsx View on Github external
({ query }) => {
    const { kind, operation } = getMainDefinition(query);
    return kind === 'OperationDefinition' && operation === 'subscription';
  },
  wsLink,
github serranoarevalo / nuber / client / src / apollo.ts View on Github external
({ query }) => {
    const { kind, operation }: any = getMainDefinition(query);
    return kind === "OperationDefinition" && operation === "subscription";
  },
  wsLink,
github awslabs / aws-mobile-appsync-sdk-js / packages / aws-appsync / src / deltaSync.ts View on Github external
const updateBaseWithDelta = (
    logger,
    baseQuery: BuildBaseQuerySyncOptions,
    otherQuery: BuildQuerySyncOptions,
    cache: DataProxy,
    data: T,
    cacheUpdates: (item: T) => QueryWithVariables[] = () => [] as QueryWithVariables[],
    typename: string,
    idField: string = 'id',
) => {
    const updateLogger = logger.extend('update');

    const opDefinition = getMainDefinition(otherQuery.query);
    const { name: { value: opName }, alias: opAliasNode } = opDefinition.selectionSet.selections[0] as FieldNode;
    const { value: opAlias = null } = opAliasNode || {};

    const { kind, operation: graphqlOperation } = opDefinition as OperationDefinitionNode;
    const isSubscription = kind === 'OperationDefinition' && graphqlOperation === 'subscription';

    const [deltaOperationName] = isSubscription ? Object.keys(data) : [opAlias || opName];
    const { [deltaOperationName]: records }: { [key: string]: any } = data;
    const deltaRecords = [].concat(records) as T[];

    if (!baseQuery || !baseQuery.query) {
        updateLogger('No baseQuery provided');
    } else {
        const { query, variables } = baseQuery;

        const operationName = getOperationFieldName(query);
github hasura / graphql-engine / community / examples / realtime-poll / src / apollo.js View on Github external
({ query }) => {
    const { kind, operation } = getMainDefinition(query);
    return kind === 'OperationDefinition' && operation === 'subscription';
  },
  wsLink,
github Akryum / vue-cli-plugin-apollo / graphql-client / src / index.js View on Github external
({ query }) => {
            const { kind, operation } = getMainDefinition(query)
            return kind === 'OperationDefinition' &&
              operation === 'subscription'
          },
          wsLink,
github OpenNeuroOrg / openneuro / packages / openneuro-client / src / client.js View on Github external
({ query }) => {
        const { kind, operation } = getMainDefinition(query)
        return kind === 'OperationDefinition' && operation === 'subscription'
      },
      ws,