Open blueandhack opened 4 years ago
Are you using relay classic or modern?
For Relay modern, there is no need to use graphql-compose-relay
.
Are you using relay classic or modern?
For Relay modern, there is no need to use
graphql-compose-relay
.
Alright, I think I use Relay modern, I just create a simple example project to try, then it works. Thanks. BTW, for my current production project, when I upgrade to version 9, I face a lot of function names that need changes, it is too hard to upgrade the old project. But I figure out the new version has a lot of new features I desired, hahaha. 😂
@nodkz Let me start by saying this is an amazing library! Thank you!
I have a problem with integration of graphql-compose-relay
into v9. My client is running relay experimental and I use the @refetchable
directive.
@refetchable directive can only be added to fragments that are "refetchable", that is, on fragments that are on Viewer, or on Query, or on a type that implements Node (i.e. a type that has an id field).
I tried providing a recordIdFn
to my mongoose type composer but since the v9 api does not support .getResolver
for findById
anymore hence building the schema fails. Here's the reference to the code that causes the failure. Are there any workarounds?
Ok so I looked at the source code a little bit more and noticed that a few other APIs are also exposed from the graphql-compose-relay
library. I basically manually did what the library does for all of my TCs:
import composeWithRelay, {
getNodeInterface,
toGlobalId,
} from 'graphql-compose-relay';
import {schemaComposer} from 'graphql-compose';
composeWithRelay(schemaComposer.Query);
[TC1, TC2, ...].forEach((tc) => {
tc.addInterface(getNodeInterface(schemaComposer));
tc.addFields({
id: {
type: 'ID!',
description: 'The globally unique ID among all types',
resolve: (source) => toGlobalId(tc.getTypeName(), tc.getRecordId(source)),
},
});
tc.setRecordIdFn((source) => source._id);
});
So far I was able to build the project both on the server and client sides without any problems. I will let you know if this solution does not work for some reason!
Again thanks for all of these libraries. We've been having a blast with them!
When I upgrade to version 9.0 The relay plugin throw error
This is my code