How to use the react-apollo/graphql function in react-apollo

To help you get started, we’ve selected a few react-apollo 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 birkir / react-native-appstore / src / graphql / queries / list.js View on Github external
// COLLECTION
// ==========

const collectionQuery = gql`
  query collection($id: ID!) {
    Collection(id: $id) {
      id
      title
      apps {
        ...AppFragment
      }
    }
  }
  ${AppFragment}
`;
const collection = graphql(collectionQuery, {
  options: props => ({ variables: { id: props.collectionId } }),
  skip: props => !props.collectionId,
  props: ({ ownProps, data }) => ({
    data: {
      ...data,
      apps: get(data, 'Collection.apps', get(ownProps, 'apps', [])),
    },
  }),
});

// TOP APPS
// ========

const topAppsQuery = gql`
  query allApps(
    $first: Int
github birkir / react-native-appstore / src / graphql / queries / app.js View on Github external
description_contains: " ",
        }
      ) {
        id
        title
        description
        createdAt
        rating
        name
      }
    }
  }
  ${AppFragment}
`;

export const appWithProps = graphql(query, {
  options: props => ({
    variables: {
      id: props.app.id,
    },
  }),
  // Attempt to re-use passed props while loading
  props: ({ ownProps, data }) => ({
    data: {
      ...data,
      App: {
        ...ownProps.app,
        ...data.App,
      },
    },
  }),
});
github birkir / react-native-appstore / src / graphql / queries / stories.js View on Github external
imageUrl
      legend
      title
      date
      app {
        ...AppFragment
      }
      apps {
        ...AppFragment
      }
    }
  }
  ${AppFragment}
`;

export default graphql(query, {
  options: props => ({
    variables: {
      first: props.first || 10,
    },
  }),
});
github birkir / react-native-appstore / src / graphql / queries / list.js View on Github external
) {
    allApps(
      filter: {
        id_not: $id
        categories_some: {
          id_in: $categories
        }
      }
    ) {
      ...AppFragment
    }
  }
  ${AppFragment}
`;

const relatedCategoriesApps = graphql(relatedCategoriesAppsQuery, {
  options: ({ appId, relatedCategoryIds = [] }) => ({
    variables: {
      filter: {
        ...(appId && { id_not: appId }),
        ...({ categories_some: { id_in: relatedCategoryIds } }),
      },
    },
  }),
  skip: props => !props.relatedCategoryIds,
  props: ({ ownProps, data }) => ({
    data: {
      ...data,
      apps: get(data, 'allApps', get(ownProps, 'apps', [])),
    },
  }),
});
github ahmedlhanafy / guchub / src / screens / Attendance.js View on Github external
const QUERY = gql`
  query AttendanceQuery($token: String!) {
    authenticatedStudent(token: $token) {
      isAuthorized
      courses {
        name
        absence {
          level
          severity
        }
      }
    }
  }
`;

export default graphql(QUERY, {
  options: graphqlCredentialsOptions,
})(Attendance);
github birkir / react-native-appstore / src / graphql / queries / list.js View on Github external
$after: String
    $filter: AppFilter
  ) {
    allApps(
      orderBy: score_DESC
      first: $first
      after: $after
      filter: $filter
    ) {
      ...AppFragment
    }
  }
  ${AppFragment}
`;

const topApps = graphql(topAppsQuery, {
  options: ({ type, top, categoryIds = [] }) => ({
    variables: {
      filter: {
        type,
        ...(top === 'PAID' ? { price_not: null } : { price: null }),
        ...(categoryIds.length > 0 ? { categories_some: { id_in: categoryIds } } : {}),
      },
    },
  }),
  skip: props => !props.top,
  props: ({ ownProps, data }) => ({
    data: {
      ...data,
      apps: get(data, 'allApps', get(ownProps, 'apps', [])),
    },
  }),
github birkir / react-native-appstore / src / graphql / queries / collections.js View on Github external
) {
      id
      title
      appType
      type
      position
      rows
      apps {
        ...AppFragment
      }
    }
  }
  ${AppFragment}
`;

export default graphql(query, {
  options: props => ({
    variables: {
      appType: props.type,
    },
  }),
});
github birkir / react-native-appstore / src / graphql / queries / topApps.js View on Github external
$after: String
    $filter: AppFilter
  ) {
    apps: allApps(
      orderBy: score_DESC
      first: $first
      after: $after
      filter: $filter
    ) {
      ...AppFragment
    }
  }
  ${AppFragment}
`;

export default graphql(topAppsQuery, {
  options: ({
    size,
    type,
    top,
    categoryIds = [],
  }) => ({
    variables: {
      first: size,
      filter: {
        type,
        ...(top === 'PAID' ? { price_not: null } : { price: null }),
        ...(categoryIds.length > 0 ? { categories_some: { id_in: categoryIds } } : {}),
      },
    },
  }),
});
github birkir / react-native-appstore / src / graphql / queries / relatedApps.js View on Github external
first: 15
      filter: {
        id_not: $id,
        type: $type,
        categories_some: {
          id_in: $categories
        }
      }
    ) {
      ...AppFragment
    }
  }
  ${AppFragment}
`;

export default graphql(query, {
  options: props => ({
    variables: {
      id: props.id,
      type: props.type,
      categories: props.categories,
    },
  }),
});
github ahmedlhanafy / guchub / src / screens / Home.js View on Github external
...CourseFragment
        weekday
      }
      transcript {
        semesters {
          year
          gpa
        }
      }
    }
  }
  ${Card.fragment}
`;

export default compose(
  graphql(QUERY, {
    options: graphqlCredentialsOptions,
  }),
  withTheme
)(Home);