How to use the graphql.GraphQLObjectType function in graphql

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github the-control-group / authx / packages / authx / src / graphql / GraphQLContact.ts View on Github external
export const GraphQLContactTag: GraphQLObjectType<
  ContactTag
> = new GraphQLObjectType({
  name: "ContactTag",
  fields: plural
});

export const GraphQLContactRelationship: GraphQLObjectType<
  ContactRelationship
> = new GraphQLObjectType({
  name: "ContactRelationship",
  fields: plural
});

export const GraphQLContact: GraphQLObjectType = new GraphQLObjectType(
  {
    name: "Contact",
    description:
      "Portable Contact. Schema defined by http://portablecontacts.net/draft-spec.html",
    fields: () => ({
      // fixed
      id: {
        type: new GraphQLNonNull(GraphQLID),
        description:
          "Unique identifier for the Contact. Each Contact returned MUST include a non-empty id value. This identifier MUST be unique across this user's entire set of Contacts, but MAY not be unique across multiple users' data. It MUST be a stable ID that does not change when the same contact is returned in subsequent requests. For instance, an e-mail address is not a good id, because the same person may use a different e-mail address in the future. Usually, in internal database ID will be the right choice here, e.g. \"12345\"."
      },

      // user configurable
      displayName: {
        type: GraphQLString,
        description:
github lifeomic / json-schema-to-graphql-types / test / converter.js View on Github external
function makeSchemaForType (output, input) {
  const queryType = new GraphQLObjectType({
    name: 'Query',
    fields: {
      findOne: { type: output }
    }
  });

  const mutationType = input ? new GraphQLObjectType({
    name: 'Mutation',
    fields: {
      create: {
        args: {input: {type: input}},
        type: output
      }
    }
  }) : undefined;

  return new GraphQLSchema({query: queryType, mutation: mutationType});
}
github larsbs / graysql / test / support / test-schema.js View on Github external
id: { type: graphql.GraphQLInt }
      },
      resolve: (_, args) => DB.getGroup(args.id)
    },
    user: {
      type: User,
      args: {
        id: { type: new graphql.GraphQLNonNull(graphql.GraphQLInt) }
      },
      resolve: (_, args) => DB.getUser(args.id)
    }
  })
});


const Mutation = new graphql.GraphQLObjectType({
  name: 'Mutation',
  fields: () => ({
    createUser: {
      type: User,
      args: {
        nick: { type: new graphql.GraphQLNonNull(graphql.GraphQLString) }
      },
      resolve: (_, args) => ({ id: 5, nick: args.nick })
    }
  })
});


const Schema = new graphql.GraphQLSchema({
  query: Query,
  mutation: Mutation
github youshido-php / GraphQL / examples / js / index.js View on Github external
}
            },
            pageContentInterface: {
                type: new GraphQLList(contentBlockInterface),
                resolve: () => {
                    return [DataProvider.getPost(2), DataProvider.getBanner(3)];
                }
            },
            enumNull: {
                type: postStatus,
                resolve: () => {
                    return null;
                }
            },
            scalarList: {
                type: new GraphQLList(new GraphQLObjectType({
                    name: 'scalarObject',
                    fields: {
                        id: {type: GraphQLInt},
                        cost: {type: GraphQLInt}
                    }
                })),
                args: {
                    count: {type: GraphQLInt, defaultValue: "12"}
                },
                resolve: (source, args) => {
                    console.log(args['count'], (args['count'] === "12"));
                    return [
                        {
                            id: 1,
                            cost: 2
                        },
github artsy / metaphysics / src / schema / v1 / show.ts View on Github external
exclude: {
    type: new GraphQLList(GraphQLString),
    description:
      "List of artwork IDs to exclude from the response (irrespective of size)",
  },
  for_sale: {
    type: GraphQLBoolean,
    defaultValue: false,
  },
  published: {
    type: GraphQLBoolean,
    defaultValue: true,
  },
}

export const ShowType = new GraphQLObjectType({
  name: "Show",
  interfaces: [NodeInterface],
  fields: () => ({
    ...SlugAndInternalIDFields,
    cached,
    artists: {
      description: "The Artists presenting in this show",
      type: new GraphQLList(Artist.type),
      resolve: ({ artists }) => {
        return artists
      },
    },
    artworks: {
      description: "The artworks featured in this show",
      deprecationReason: deprecate({
        inVersion: 2,
github JasonEtco / flintcms / server / graphql / types / Plugins.js View on Github external
description: 'Title of the plugin.'
    },
    version: {
      type: new GraphQLNonNull(GraphQLString),
      description: 'Version of the plugin, ideally a semver.'
    },
    uid: {
      type: new GraphQLNonNull(GraphQLString),
      description: 'UID of the plugin.'
    },
    name: {
      type: new GraphQLNonNull(GraphQLString),
      description: 'Name of the plugin class.'
    },
    icon: {
      type: new GraphQLObjectType({
        name: 'PluginIcon',
        fields: {
          path: {
            type: new GraphQLNonNull(GraphQLString),
            description: 'The path, from the plugin\'s entry point to the icon file.'
          },
          buffer: {
            type: new GraphQLNonNull(GraphQLString),
            resolve: plug => plug.buffer.toString('base64'),
            description: 'The buffer for the plugin\'s icon.'
          }
        }
      })
    },
    dateInstalled: {
      type: new GraphQLNonNull(DateTime),
github RevJS / revjs / packages / rev-api / src / graphql / schema.ts View on Github external
export function getGraphQLSchema(manager: ModelApiManager): GraphQLSchema {

    const schema: GraphQLSchemaConfig = {} as any;

    const queryConfig = getQueryConfig(manager);
    const mutationConfig = getMutationConfig(manager);

    schema.query = new GraphQLObjectType(queryConfig);
    if (mutationConfig) {
        schema.mutation = new GraphQLObjectType(mutationConfig);
    }

    return new GraphQLSchema(schema);
}
github carlos-kelly / publications / src / platform / schemas / document.ts View on Github external
text: { type: GraphQLString },
};

const pageFields = {
  id: { type: GraphQLID },
  width: { type: GraphQLFloat },
  height: { type: GraphQLFloat },
  pageNumber: { type: GraphQLInt },
};

const documentFields = {
  id: { type: GraphQLID },
  name: { type: GraphQLString },
};

const ShapeType = new GraphQLObjectType({
  name: "Shape",
  fields: {
    id: { type: GraphQLID },
    ...shapeFields,
  },
});

const ShapeInputType = new GraphQLInputObjectType({
  name: "ShapeInput",
  fields: {
    ...shapeFields,
  },
});

const PageType = new GraphQLObjectType({
  name: "Page",
github Asymmetrik / graphql-fhir / src / resources / 1_0_2 / schemas / immunization.schema.js View on Github external
GraphQLUnionType,
	GraphQLBoolean,
	GraphQLString,
	GraphQLObjectType,
} = require('graphql');
const IdScalar = require('../scalars/id.scalar.js');
const UriScalar = require('../scalars/uri.scalar.js');
const CodeScalar = require('../scalars/code.scalar.js');
const DateTimeScalar = require('../scalars/datetime.scalar.js');
const DateScalar = require('../scalars/date.scalar.js');

/**
 * @name exports
 * @summary Immunization Schema
 */
module.exports = new GraphQLObjectType({
	name: 'Immunization',
	description: 'Base StructureDefinition for Immunization Resource',
	fields: () => ({
		resourceType: {
			type: new GraphQLNonNull(
				new GraphQLEnumType({
					name: 'Immunization_Enum_schema',
					values: { Immunization: { value: 'Immunization' } },
				}),
			),
			description: 'Type of resource',
		},
		_id: {
			type: require('./element.schema.js'),
			description:
				'The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.',