How to use the nexus.queryField function in nexus

To help you get started, we’ve selected a few nexus examples, based on popular ways it is used in public projects.

github este / este / packages / api / schema / user.ts View on Github external
name: 'User',
  definition(t) {
    t.id('id');
    t.dateTime('createdAt');
    t.dateTime('updatedAt');
    t.string('email');
    t.string('themeName');
    t.list.field('webs', {
      type: 'Web',
      resolve: (root, _args, context) => context.models.user.webs(root.id),
    });
  },
});

// https://medium.com/workflowgen/graphql-schema-design-the-viewer-field-aeabfacffe72
export const viewer = queryField('viewer', {
  type: User,
  nullable: true,
  resolve: (_root, _args, context) => context.models.user.viewer(),
});

// requiredViewer throws, so the app can redirect.
export const requiredViewer = queryField('requiredViewer', {
  type: User,
  resolve: (_root, _args, context) => context.models.user.requiredViewer(),
});

export const SignInInput = inputObjectType({
  name: 'SignInInput',
  definition(t) {
    t.string('email');
    t.string('password');
github este / este / packages / api / schema / user.ts View on Github external
t.list.field('webs', {
      type: 'Web',
      resolve: (root, _args, context) => context.models.user.webs(root.id),
    });
  },
});

// https://medium.com/workflowgen/graphql-schema-design-the-viewer-field-aeabfacffe72
export const viewer = queryField('viewer', {
  type: User,
  nullable: true,
  resolve: (_root, _args, context) => context.models.user.viewer(),
});

// requiredViewer throws, so the app can redirect.
export const requiredViewer = queryField('requiredViewer', {
  type: User,
  resolve: (_root, _args, context) => context.models.user.requiredViewer(),
});

export const SignInInput = inputObjectType({
  name: 'SignInInput',
  definition(t) {
    t.string('email');
    t.string('password');
    t.boolean('createAccount');
  },
});

export const SignInErrors = objectType({
  nonNullDefaults: { output: false },
  name: 'SignInErrors',
github jferrettiboke / stripe-graphql / src / graphql / products / queries / product.ts View on Github external
import { queryField, idArg } from "nexus";

export const productQueryField = queryField("product", {
  type: "Product",
  nullable: true,
  args: {
    id: idArg({ required: true })
  },
  async resolve(root, { id }, context, info) {
    return await context.stripe.products.retrieve(id);
  }
});
github jferrettiboke / stripe-graphql / src / graphql / country-specs / queries / countrySpecs.ts View on Github external
import { stringArg, queryField } from "nexus";

export const countrySpecsQueryField = queryField("countrySpecs", {
  type: "CountrySpec",
  nullable: true,
  args: {
    country: stringArg({ required: true })
  },
  async resolve(root, { country }, context, info) {
    return await context.stripe.countrySpecs.retrieve(country);
  }
});
github jferrettiboke / stripe-graphql / src / graphql / products / queries / products.ts View on Github external
import { queryField } from "nexus";

export const productsQueryField = queryField("products", {
  type: "Product",
  list: true,
  async resolve(root, args, context, info) {
    const { data } = await context.stripe.products.list();
    return data;
  }
});
github jferrettiboke / stripe-graphql / src / graphql / plans / queries / plan.ts View on Github external
import { queryField, idArg } from "nexus";

export const planQueryField = queryField("plan", {
  type: "Plan",
  nullable: true,
  args: {
    id: idArg({ required: true })
  },
  async resolve(root, { id }, context, info) {
    return await context.stripe.plans.retrieve(id);
  }
});
github este / este / packages / api / schema / web.ts View on Github external
queryField,
  idArg,
} from 'nexus';

export const Web = objectType({
  name: 'Web',
  definition(t) {
    t.id('id');
    t.dateTime('createdAt');
    t.dateTime('updatedAt');
    t.string('name');
    t.field('creator', { type: 'User' });
  },
});

export const web = queryField('web', {
  type: Web,
  args: { id: idArg() },
  resolve: (_root, { id }, context) => context.models.web.byId(id),
});

export const CreateWebInput = inputObjectType({
  name: 'CreateWebInput',
  definition(t) {
    t.string('name');
  },
});

export const CreateWebErrors = objectType({
  nonNullDefaults: { output: false },
  name: 'CreateWebErrors',
  definition(t) {