{"id":25522315,"url":"https://github.com/launchscout/react-apollo-subscribed-query","last_synced_at":"2026-03-02T22:11:47.240Z","repository":{"id":136334447,"uuid":"104781620","full_name":"launchscout/react-apollo-subscribed-query","owner":"launchscout","description":"Wraps a react component a query and a subscription that updates it","archived":false,"fork":false,"pushed_at":"2017-09-25T18:00:52.000Z","size":4,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-23T23:14:37.677Z","etag":null,"topics":["apollo","apollographql","graphql","react"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchscout.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-25T17:37:26.000Z","updated_at":"2018-08-18T10:50:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5096da9-2dcf-4579-8082-069514a613d5","html_url":"https://github.com/launchscout/react-apollo-subscribed-query","commit_stats":null,"previous_names":["gaslight/react-apollo-subscribed-query"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Freact-apollo-subscribed-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Freact-apollo-subscribed-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Freact-apollo-subscribed-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchscout%2Freact-apollo-subscribed-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchscout","download_url":"https://codeload.github.com/launchscout/react-apollo-subscribed-query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325116,"owners_count":21084870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","apollographql","graphql","react"],"created_at":"2025-02-19T18:19:18.625Z","updated_at":"2026-03-02T22:11:42.212Z","avatar_url":"https://github.com/launchscout.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-apollo-subscribed-query\n\nThis module exports a single function that you can use like so\nto wrap a React component with a graphql query and a subscription\nthat will update its results.\n\n## Example\n\n```javascript\nimport React, { Component } from 'react';\nimport {\n  ApolloClient,\n  gql,\n  graphql,\n  ApolloProvider,\n} from 'react-apollo';\nimport ProcessOrder from './ProcessOrder';\nimport graphqlSubscribedQuery from 'react-apollo-subscribed-query';\n\nclass OrderDetail extends Component {\n\n  render() {\n    const {match} = this.props;\n    const {loading, error, order} = this.props.data;\n    if (loading) {\n     return \u003cp\u003eLoading ...\u003c/p\u003e;\n    }\n    if (error) {\n     return \u003cp\u003e{error.message}\u003c/p\u003e;\n    }\n    return (\n      \u003cdiv className=\"OrderDetail\"\u003e\n        \u003cdl\u003e\n          \u003cdt\u003ePurchase Order Number\u003c/dt\u003e\n          \u003cdd\u003e{order.purchaseOrderNumber}\u003c/dd\u003e\n        \u003c/dl\u003e\n        \u003cdl\u003e\n          \u003cdt\u003eStatus\u003c/dt\u003e\n          \u003cdd\u003e{order.status}\u003c/dd\u003e\n        \u003c/dl\u003e\n        \u003cdl\u003e\n          \u003cdt\u003eProduction Quantity\u003c/dt\u003e\n          \u003cdd\u003e{order.productionQuantity}\u003c/dd\u003e\n        \u003c/dl\u003e\n        \u003cdl\u003e\n          \u003cdt\u003eTest Quantity\u003c/dt\u003e\n          \u003cdd\u003e{order.testQuantity}\u003c/dd\u003e\n        \u003c/dl\u003e\n        \u003cdl\u003e\n          \u003cdt\u003eItem Schema\u003c/dt\u003e\n          \u003cdd\u003e{order.itemSchema}\u003c/dd\u003e\n        \u003c/dl\u003e\n        \u003cProcessOrder order={order} /\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport const orderQuery = gql`\n   query OrderQuery($orderId: ID) {\n     order(orderId: $orderId) {\n       id\n       purchaseOrderNumber\n       status\n       testQuantity\n       productionQuantity\n       itemSchema\n     }\n   }\n `;\n\nexport const orderSubscription = gql`\n  subscription subscribeToOrders($orderId:ID!) {\n    orderStatusChange(orderId: $orderId) {\n      id\n      status\n      itemSchema\n      testQuantity\n      productionQuantity\n      purchaseOrderNumber\n    }\n  }\n`;\nconst OrderDetailWithQuery = graphqlSubscribedQuery({\n  options: ({ match }) =\u003e ({ variables: { orderId: match.params.orderId } }),\n  query: orderQuery,\n  subscription: orderSubscription\n})(OrderDetail);\nexport default OrderDetailWithQuery;\n```\n\nCaveats:\n\n* query and subscription must take the same variables\n* subscription data will replace query data\n* This is really just a spike. It appears to work but there are no tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Freact-apollo-subscribed-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchscout%2Freact-apollo-subscribed-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchscout%2Freact-apollo-subscribed-query/lists"}