profile
viewpoint

cnnlabs/cnn-hapi 11

CNN Hapi

cnnlabs/cnn-metrics 3

CNN Metrics

cnnlabs/cnn-health 1

CNN Health

issue commentgraphql-compose/graphql-compose

Trying to use ApolloFederation..

@nodkz Returning the string representation of type name is accepted, and works in other parts our apps. I did replace it with your suggestion above, but got the same error.

MDrooker

comment created time in a month

issue commentgraphql-compose/graphql-compose

Trying to use ApolloFederation..

I have a union type defined like-

const Content = schemaComposer.createUnionTC({
    name: 'Content',
    types: ['videoContent', 'articleContent', 'podcast'],
    resolveType(value) {
        switch (value.type) {
            case "curatedClip":
                return 'videoContent';
                break;
            case "publishedArticle":
                return 'articleContent'
                break;
            case "wm.podcast":
                return 'podcast'
                break;
            default:
                console.log('---------------')
                return null;
                break
        }
    }
});

When I use when trying to implement federation with Apollo-

const sdl = schemaComposer.toSDL({ exclude: ['Boolean', 'String', 'Subscription'] });
 server = new ApolloServer({
        subscriptionsPath: subscriptionsPath,
        schema: buildFederatedSchema([
            {
                typeDefs: gql(sdl),
                resolvers: resolveMethods
            },
        ]),

I get an error - "Abstract type "Content" must resolve to an Object type at runtime for field "contentSet.contents" with ..., received "undefined". Either the "Content" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function."

That type does have a resolveType function.

Yet when use it-

      server = new ApolloServer({
        subscriptionsPath: subscriptionsPath,
        schema,

It resolves and executes as expected. Could there be an issue with with the toSDL and UnionTypes?

MDrooker

comment created time in 2 months

more