Code Monkey home page Code Monkey logo

Comments (8)

benjie avatar benjie commented on September 20, 2024 1

Fixed in v1 πŸ‘

from operation-hooks.

parris avatar parris commented on September 20, 2024

I think I got it working, this is either a workaround or it should be in the documentation:

So I added a very simply resolver for the subscription:

    resolvers: {
      CommunityFeedItemCommentSubscriptionPayload: {
        async communityFeedItemComment(...args) {
          return require('./resolver').default(sql, ...args); // eslint-disable-line global-require
        },
      },
      Subscription: {
        communityFeedItemCommentAdded: (event) => ({ event }),
      },
    },

The event needs to get passed through so we have access the to the subject in the Payload resolver.

After that, everything seems to connect and work properly. Look aheads work, the query builder effectively does the look ahead and the resulting sql executed/produced seems accurate (based on looking at the query logs and debugging.

from operation-hooks.

benjie avatar benjie commented on September 20, 2024

@parris Can you confirm the order in which you're loading the pubsub and operationhooks plugins? I think you have to load pubsub first, then operation hooks.

from operation-hooks.

parris avatar parris commented on September 20, 2024

@benjie ahh - maybe that's it const pluginHook = makePluginHook([OperationHooks, PgPubsub, GraphilePro]);

from operation-hooks.

parris avatar parris commented on September 20, 2024

I was following the order found here https://www.graphile.org/postgraphile/plugins/ if I recall correctly. Perhaps the doc should get modified?

from operation-hooks.

benjie avatar benjie commented on September 20, 2024

@parris Can you confirm if this solved the issue? If so, a mod to the doc would be welcome πŸ‘

from operation-hooks.

parris avatar parris commented on September 20, 2024

@benjie - I had a chance to look into this. Changing the order of the hooks does not impact this. In a fresh project (not using any other libraries between postgraphile and the codebase), and using mutations instead of subscriptions I've found the same thing to occur.

Example:

makeExtendSchemaPlugin(({ pgSql: sql }) => ({
    typeDefs: gql`
      type AuthenticationDetails {
        person: Person!
        jwtToken: String!
      }
      type RegisterPayload {
        authenticationDetails: AuthenticationDetails!
      }
    `,
     resolvers: {
      RegisterPayload: {
        async authenticationDetails(...args) {
          return resolver.registerPerson(sql, ...args);
        },
      },
    },
  },
} as ExtensionDefinition)),

This will throw Error: Default resolver found for field Mutation.registerPerson; default resolvers at the root level are not supported by operation-hooks

However, even doing something as simple as the following resolves the issue.

Mutation: {
   registerPerson: () => ({}),
}

from operation-hooks.

benjie avatar benjie commented on September 20, 2024

My guess is that things are running out of phase - operation hooks is trying to mod the resolver before it’s added by makeExtendSchemaPlugin. I’m not sure what we can do about this in v4.

from operation-hooks.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.