-
Notifications
You must be signed in to change notification settings - Fork 470
Strategy for @client directive #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Duplicate of #275 ? |
I'm also curious, what will be the way to handle |
Right now, having a Similar to what merge-graphql-schemas does but with the difference that all types are merged together. |
It would be great to not have to exclude the whole file, as one of the promises of apollo-link-state is that you can get client-cached and remote data all in one query (once apollographql/apollo-link-state#140 is fixed, at least). Plus, it would be good to have type-safety on even those local client operations. Having those client fields at least set to |
@kohlikohl, given that Urigo/merge-graphql-schemas#118 has been merged, do you mind sharing how you made this all work for |
@majelbstoat This is exactly what I am doing. |
If anyone wants to work on incorporating a solution for this in |
I'm currently pre-processing my queries to strip the |
Working on an extension for the |
I wrote a small script to merge the remote GraphQL schema with my apollo-link-state local/client schemas, not sure if its the right way though. Hope it helps anyone. |
@zhenwenc's script worked perfectly for me. I created a |
@zhenwenc thx for the snippet worked for me too 👍 |
@zhenwenc Thanks for your script, works perfect As @nihaux mentioned, it's necessary to add
Add
Setting |
Thanks @nihaux and @nilshartmann for pointing out the issue. 👍 |
@zhenwenc saved my life man!!! |
Exciting update to share, we are working on official support for the |
Support for the |
Is there a complete example where the schema is downloaded from the remote graphql server, combined with the local state, then generate the type definition files? I cannot seem to get this working (using apollo cli version 1.7.0) |
Any documentation around how to do this would be helpful. I'm also having issues getting this to work. |
I needed to generate typings for local state & remote queries. After few unproductive hours with errors like: Or trying to merge schema like in gist above and getting: I could not even recreate unit tests and then with rage I deleted My guess is that apollo-cli cannot read @greatwitenorth @danielwong2268 try it! Example based on unit tests for anyone in need
# src/state/schema.graphql
extend type Query { # needs to extend if type exists server-side
localState: String!
complexLocalState: LocalType!
}
type LocalType {
someData: String!
}
// src/components/SomeComponent.tsx
const GET_STUFF= gql`
# some server query
query SimpleQuery {
users {
id
}
# and some local
localState @client
complexLocalState @client {
someData
}
}
`
$ apollo codegen:generate generated \
--queries=src/components/**/*.tsx \
--target typescript \
--schema src/generated/schema.json \
--clientSchema src/state/schema.graphql I'm so happy, that it works 🙃 |
@vadistic thank you for that!. I hit the same issue yesterday and was blocked by it this morning. I agree that some better error messaging would be helpful here. I may work on a PR to help with that (and maybe some docs too). |
For anyone else running into this issue, I had x2 problems:
|
In
While trying Did the argument change? I was looking into the codegen there's actually no argument to pass local schema. Has this been updated and removed somehow? I'm still not sure how this |
@bsunderhus Since apollo v2, a client schema does not need to be explicitly defined anymore. It should be evaluated appropriately if it is part of the See this issue: #696 (comment) |
I've noticed. I actually ended up opening the issue #731 just for this, and once I've finally found this information I immediately closed it! Totally forgot about commenting here, sorry @ZenSoftware |
Oh and actually, I'm using a query to get only |
Hello!
What would be the strategy for
@client
directive? Just ignore the whole file or ignore only aclient
part?Thanks
The text was updated successfully, but these errors were encountered: