Graphclient generates unknown type `DocumentNode`
wanglonghong opened this issue · comments
Error details
File: .graphclient/index.ts
error: Parameter 'doc' of exported function has or is using private name 'DocumentNode'.ts(4078)
export async function getBuiltGraphSDK<TGlobalContext = any, TOperationContext = any>(globalContext?: TGlobalContext) {
const { sdkRequesterFactory } = await getBuiltGraphClient();
return getSdk<TOperationContext>(sdkRequesterFactory(globalContext));
}
export type Requester<C = {}> = <R, V>(doc: **_DocumentNode_**, vars?: V, options?: C) => Promise<R>;
export function getSdk<C>(requester: Requester<C>) {
return {};
}
export type Sdk = ReturnType<typeof getSdk>;
How to reproduce the above issue?
Its so simple. just to run the following script. graphclient build --tsOnly
. This command generates typescript files but also generates unknown type => DocumentNode
. This type throws when trying to build the typescript project using tsc --build ./tsconfig.build.json
Temporary Fix
If I replace DocumentNode with any
after graphclient build, typescript build works. but it is not a preferrable way.
Is there a way to fix this when running graphclient build --tsOnly
Thanks
@ardatan what do you think?
I need a reproduction because I've never seen this kind of error in our example :/
I need a reproduction because I've never seen this kind of error in our example :/
I think I saw this issue in older versions, probably 0.0.3
and it was fixed already in Mesh. Should be fine. Let's wait for @wanglonghong 's update on that. 0.0.6
should fix that.
@dotansimha. already tried with 0.0.6
but it still generates an unknown DocumentNode
type.
import {
GraphQLResolveInfo,
SelectionSetNode,
FieldNode,
GraphQLScalarType,
GraphQLScalarTypeConfig,
} from "graphql";
I think this is the right position where we have to import DocumentNode
. because DocumentNode
is already defined in graphql
package
I have to reproduce it by myself with bunch of trial and errors because you didn't provide one. Next time please provide it to help us to debug it faster :) So DocumentNode
import is missing only if you don't have any documents defined in the configuration. Until this gets fixed, you can provide some as a workaround.
Thanks @ardatan . yeah, I didn't have any documents defined in the configuration. Ok. I follow up on your temporary fix and will make sure to help you to debug faster since next time.
I attach the example with DocumentNode
issue.
https://github.com/wanglonghong/graphclient-test
How to reproduce the issue?
$ yarn build-client
$ yarn build
I know you got this case yourself by doing a bunch of trials. I hope this would be helpful for you to fix it completely. Thanks
Could you try with the latest versions? It should be fixed with the latest release.
Ok. will try with the latest version and keep u updated. Thanks
I think it is still the same if I upgraded the version properly.
I created an action in the same repo. (https://github.com/wanglonghong/graphclient-test)
you can see the logs here.
https://github.com/wanglonghong/graphclient-test/runs/6573271048?check_suite_focus=tru
Seems like we need to cut a release with the latest Mesh. Will be done tomorrow :) Sorry for the delay!
This should be fine now with 0.0.11. Another workaround to avoid this issue is to make sure to add any GraphQL query, even as dummy one like query dummy { __typename }
.