How to use the graphql-relay.globalIdField function in graphql-relay

To help you get started, we’ve selected a few graphql-relay 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 bitriddler / VineRelayStore / server / graphql / types / orderItemType.js View on Github external
fields: () => ({
    id: globalIdField('OrderItem'),
    quantity: { type: new GraphQLNonNull(GraphQLInt) },
    product: {
      // This can be null if product has been removed
      type: productType,
      resolve: (item) => item.getProduct(),
    },
  }),
  interfaces: [nodeInterface],
github ediket / nothinkdb-graphql / src / field.js View on Github external
export function getGraphQLFieldsFromTable(table) {
  const schema = table.getSchema();

  return {
    ...getGraphQLfieldsFromSchema(_.omit(schema, table.pk)),
    [table.pk]: globalIdField(table.tableName),
  };
}
github soonlive / relay-cart / data / types / cartType.js View on Github external
fields: () => ({
    id: globalIdField('Cart'),
    entries: {
      type: cartEntryConnectionType,
      args: connectionArgs,
      resolve: ({ entries }, args) => {
        logger.info('Resolving cartType.entries with params:', args);

        const connection = connectionFromArray(
          entries,
          args,
        );
        return connection;
      },
    },
    totalNumberOfItems: {
      type: GraphQLInt,
    },
github fortruce / relay-skeleton / src / server / data / schema.js View on Github external
fields: () => ({
    id: globalIdField('Example'),
    text: {
      type: GraphQLString,
      description: 'Hello World'
    }
  }),
  interfaces: [ nodeInterface ]
github Pathgather / smashgather / server / server / data / schema.js View on Github external
fields: () => ({
    id: globalIdField("Character"),
    name: {
      type: GraphQLString,
      description: "The name of the character",
    },
    wins: {
      type: GraphQLInt,
      description: "The number of wins for the character",
    },
  }),
  interfaces: [nodeInterface],
github parse-community / parse-server / src / GraphQL / loaders / parseClassTypes.js View on Github external
description: 'The fields to be used when sorting the data fetched.',
      type: classGraphQLOrderType
        ? new GraphQLList(new GraphQLNonNull(classGraphQLOrderType))
        : GraphQLString,
    },
    skip: defaultGraphQLTypes.SKIP_ATT,
    ...connectionArgs,
    options: defaultGraphQLTypes.READ_OPTIONS_ATT,
  };
  const classGraphQLOutputTypeName = `${graphQLClassName}`;
  const interfaces = [
    defaultGraphQLTypes.PARSE_OBJECT,
    parseGraphQLSchema.relayNodeInterface,
  ];
  const parseObjectFields = {
    id: globalIdField(className, obj => obj.objectId),
    ...defaultGraphQLTypes.PARSE_OBJECT_FIELDS,
  };
  const outputFields = () => {
    return classOutputFields.reduce((fields, field) => {
      const type = transformOutputTypeToGraphQL(
        parseClass.fields[field].type,
        parseClass.fields[field].targetClass,
        parseGraphQLSchema.parseClassTypes
      );
      if (parseClass.fields[field].type === 'Relation') {
        const targetParseClassTypes =
          parseGraphQLSchema.parseClassTypes[
            parseClass.fields[field].targetClass
          ];
        const args = targetParseClassTypes
          ? targetParseClassTypes.classGraphQLFindArgs
github gaoxiaoliangz / readr / src / server / graphql / gql-types / gql-reading-progress.ts View on Github external
fields: () => ({
    id: globalIdField('ReadingProgress'),
    percentage: {
      type: GraphQLFloat
    }
  })
})
github danscan / datomic-graphql / src / graphQLSchema / utils / typeRegistry.js View on Github external
fields: () => ({
      id: globalIdField(entityTypeName),
      ...(mapObject(entityType, attribute => ({
        type: getGraphQLTypeForAttribute(attribute),
        description: attribute.doc,
      }))),
    }),
    interfaces: [nodeInterface],
github kriasoft / nodejs-api-starter / src / schema / comment / CommentType.js View on Github external
fields: () => ({
    id: globalIdField(),

    story: {
      type: new GraphQLNonNull(StoryType),
      resolve(parent, args, ctx: Context) {
        return ctx.storyById.load(parent.story_id);
      },
    },

    parent: {
      type: CommentType,
      resolve(parent, args, ctx: Context) {
        return parent.parent_id && ctx.commentById.load(parent.parent_id);
      },
    },

    author: {
github JedWatson / sydjs-site / graphql / relaySchema.js View on Github external
fields: () => ({
		id: globalIdField('Organisation'),
		name: { type: GraphQLString },
		logo: { type: keystoneTypes.cloudinaryImage },
		website: { type: GraphQLString },
		isHiring: { type: GraphQLBoolean },
		description: { type: keystoneTypes.markdown },
		location: { type: keystoneTypes.location },
		members: {
			type: userConnection,
			args: connectionArgs,
			resolve: ({id}, args) => connectionFromPromisedArray(
				User.model.find().where('organisation', id).exec(),
				args
			),
		},
	}),
	interfaces: [nodeInterface],