Giter Site home page Giter Site logo

nexus-plugins's Issues

Generated type mismatch

Since updating to @jcm/nexus-plugin-relay-mutation 0.1.2, TypeScript types generated by Nexus do not align with the actual input argument passed to mutateAndGetPayload.

For example, if I created a Relay mutation as follows

  t.relayMutation('foo', {
    inputFields(it) {
      it.nonNull.string('bar');
    },
    outputFields(ot) {
      ot.nonNull.string('baz');
    },
    mutateAndGetPayload(_root, inputFields) {
      return {baz: inputFields.bar};
    },
  });

TypeScript will expect the type of inputFields to be

inputFields: {
  input: {
    baz: string;
    clientMutationId?: string | null | undefined;
  };
}

meanwhile the actual type is

inputFields: {
  baz: string;
  clientMutationId?: string | null | undefined;
}

Field "id" missing in typescript definition when using plugin

When I use the plugin and define id as a relayGlobalId field, it results in a type error stating that "id" is not found on the object. If I use the model ID instead of relay (uncomment line below), there is no type error, but the id is obviously not relay-compliant. I'm not sure if this is related to graphql-nexus/nexus#36 (see comment), but is there any way to get nexus to realize the id does exist on the root type?

const Task = objectType({
  name: TaskModel.$name,
  definition: (t) => {
    t.implements('Node')
    t.relayGlobalId('id', {})
    // t.field(TaskModel.id.name, TaskModel.id)
    t.connectionField('comments', {
      type: 'Comment',
      resolve: async (src, args, ctx, info) => {
        const comments = db.comment.find({
          where: {
            taskId: src.id, // <==== TypeError Here
          },
        })
      },
    })
  },
})

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.