Comments (12)
I was experimenting with using @apollo/client
as well. This works for me:
// _app.js
import { ApolloClient, ApolloProvider, InMemoryCache, createHttpLink } from '@apollo/client';
//...
function MyProvider(props) {
const app = useAppBridge();
const client = new ApolloClient({
cache: new InMemoryCache(),
link: createHttpLink({
credentials: 'include',
headers: {
"Content-Type": "application/graphql"
},
fetch: authenticatedFetch(app)
})
});
const Component = props.Component;
return (
<ApolloProvider client={client}>
<Component {...props} />
</ApolloProvider>
);
}
And using useQuery
in a component:
import { gql, useQuery } from '@apollo/client';
const GET_SHOP_NAME = gql`
query {
shop {
id
name
email
}
}
`
export default function ShopInfo() {
const { loading, error, data } = useQuery(GET_SHOP_NAME);
if (loading) return <div>Loading...</div>;
if (error) return <div>{error.message}</div>
console.log(data)
return (
<p>OK</p>
);
}
from shopify-app-template-node.
I keep getting this error even while using the code provided by @milancermak
Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider>, or pass an ApolloClient instance in via options.
from shopify-app-template-node.
The code of @milancermak worked fine for me
from shopify-app-template-node.
@milancermak you bloody legend. This took me way too long to find.
I'm also wondering what the hold up on Migrating to @apollo/client is?
from shopify-app-template-node.
I have the same issue
from shopify-app-template-node.
Hi, @paulomarg 👋 Any update on this one?
from shopify-app-template-node.
@milancermak Hi, I also use new Apollo/Client, but when do a query throw useQuery , the graphql post request occured cros error. I see your code in new ApolloClient ,you ad a authenticatedFetch, Does this line must be included ?
from shopify-app-template-node.
any update of this issue ?? @paulomarg i'm new to shopify app dev, find the react-apollo has been deprecated. I try to change it to Apollo/Client, but face query request keep loading , no error and no data return .
from shopify-app-template-node.
The code of @milancermak worked fine for me
thanks
from shopify-app-template-node.
It says to me:
statusCode: 401,
errors: '[API] Invalid API key or access token (unrecognized login or wrong password)'
from shopify-app-template-node.
This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
from shopify-app-template-node.
We are closing this issue because it has been inactive for a few months.
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!
from shopify-app-template-node.
Related Issues (20)
- Serve the app in subfolder / context path
- Could not validate request HMAC HOT 2
- There's no page at this address HOT 2
- templates not showing anymore HOT 2
- shopify-app-remix get authenticated user details HOT 1
- Build Failure with Heap Memory Error and NPM Issues on Heroku
- FortClient Virus Alert for cloudflared.exe
- UNABLE_TO_VERIFY_LEAF_SIGNATURE
- Unable to login
- Blank Page Displayed in Shopify Admin for App Deployed on Dedicated Server
- missing script "build" HOT 5
- Only remix, none template aliases are supported
- Error: "Only remix, none template aliases are supported" when initializing node template app HOT 1
- Error Upgrading @Shopify/Polaris And React In Shopify App Development HOT 2
- Incorrect Documentation in README.md HOT 1
- Incorrect Documentation in README.md HOT 6
- Request bill payment and if merchant decline payment till merchant still able to use App further
- The app couldn’t be loaded HOT 1
- pnpm template breaks when running `pnpm dev` command HOT 2
- TailwinCss does not work when installed into the project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify-app-template-node.