How to use the GraphQLNonNull function from graphql

Find comprehensive JavaScript graphql.GraphQLNonNull code examples handpicked from public code repositorys.

123
124
125
126
127
128
129
130
131
132

queryTopFields[getBy] = {
  type,
  args: {
    ...(primaryKeys.reduce((acc, primaryKey) => {
      acc[primaryKey] = { type: new graphql.GraphQLNonNull(fields[primaryKey].type) }
      return acc
    }, {}))
  }
}
fork icon85
star icon888
watch icon16

+ 131 other calls in file

4
5
6
7
8
9
10
11
12
13
const InputObjectType = graphql.GraphQLInputObjectType;
const InterfaceType = graphql.GraphQLInterfaceType;
const ScalarType = graphql.GraphQLScalarType;
const ObjectType = graphql.GraphQLObjectType;
const UnionType = graphql.GraphQLUnionType;
const NonNullType = graphql.GraphQLNonNull;
const EnumType = graphql.GraphQLEnumType;
const ListType = graphql.GraphQLList;

const builtInScalars = {
fork icon13
star icon203
watch icon10

+ 3 other calls in file

49
50
51
52
53
54
55
56
57
58
},
type: {
        type: new _graphql.GraphQLNonNull(_graphql.GraphQLString)
},
size: {
        type: new _graphql.GraphQLNonNull(_graphql.GraphQLInt)
},
path: {
        type: new _graphql.GraphQLNonNull(_graphql.GraphQLString)
}
fork icon5
star icon7
watch icon3

+ 11 other calls in file

75
76
77
78
79
80
81
82
83
84
  // filterInputObjectType is undefined if the entity only contains elements that are associations or compositions
  // updateInputObjectType is undefined if it is generated for an entity that only contains key elements
  if (!filterInputObjectType || !updateInputObjectType) return

  const args = {
    [ARGS.filter]: { type: new GraphQLNonNull(filterInputObjectType) },
    [ARGS.input]: { type: new GraphQLNonNull(updateInputObjectType) }
  }
  return { type: new GraphQLList(entityObjectType), args }
}
fork icon3
star icon23
watch icon8

+ 5 other calls in file

883
884
885
886
887
888
889
890
891
892

if ((!optional || itemColumns[i].name === "Id")
    && !itemColumns[i].nullable
    && itemColumns[i].name !== "ModifiedBy"
    && itemColumns[i].name !== "ModifiedOn") {
    fields[itemColumns[i].name[0].toLowerCase() + itemColumns[i].name.slice(1)] = { type: new graphql.GraphQLNonNull(t) };
}
else {
    fields[itemColumns[i].name[0].toLowerCase() + itemColumns[i].name.slice(1)] = { type: t };
}
fork icon3
star icon6
watch icon0

+ 23 other calls in file

24
25
26
27
28
29
30
31
32
33

var CreateProductMutation = exports.CreateProductMutation = new _graphqlRelay.mutationWithClientMutationId({
    name: 'CreateProductMutation',
    description: 'Function to create a product',
    inputFields: {
        name: { type: new _graphql.GraphQLNonNull(_graphql.GraphQLString) },
        description: { type: _graphql.GraphQLString },
        disabled: { type: _graphql.GraphQLBoolean },
        startDate: { type: _graphql.GraphQLString },
        endDate: { type: _graphql.GraphQLString },
fork icon1
star icon6
watch icon4

+ 5 other calls in file

0
1
2
3
4
5
6
7
8
9
const { GraphQLID, GraphQLString, GraphQLNonNull, GraphQLObjectType, GraphQLBoolean } = require('graphql');

exports.UserType = new GraphQLObjectType({
  name: 'User',
  fields: {
    id: { name: 'id', type: new GraphQLNonNull(GraphQLID) },
    firstName: { name: 'firstName', type: new GraphQLNonNull(GraphQLString) },
    lastName: { name: 'lastName', type: new GraphQLNonNull(GraphQLString) },
    email: { name: 'email', type: new GraphQLNonNull(GraphQLString) },
    isAdmin: { name: 'isAdmin', type: new GraphQLNonNull(GraphQLBoolean) }
fork icon2
star icon1
watch icon29

+ 9 other calls in file

26
27
28
29
30
31
32
33
34
35
  } else {
    constraintType = new ConstraintStringType(fieldName, uniqueTypeName, type, directiveArgumentMap)
  }
} else if (type === GraphQLFloat || type === GraphQLInt) {
  if (notNull) {
    constraintType = new GraphQLNonNull(new ConstraintNumberType(fieldName, uniqueTypeName, type, directiveArgumentMap))
  } else {
    constraintType = new ConstraintNumberType(fieldName, uniqueTypeName, type, directiveArgumentMap)
  }
} else {
fork icon65
star icon0
watch icon1

+ 3 other calls in file

77
78
79
80
81
82
83
84
85
86
var _this = this;
if (pubSubInstance === void 0) { pubSubInstance = null; }
return {
    type: graphql_1.GraphQLInt,
    description: "Delete a ".concat(modelName),
    args: __assign({ id: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLInt) } }, (graphqlModelDeclaration["delete"] &&
        graphqlModelDeclaration["delete"].extraArg
        ? graphqlModelDeclaration["delete"].extraArg
        : {})),
    resolve: function (source, args, context, info) { return __awaiter(_this, void 0, void 0, function () {
fork icon7
star icon20
watch icon19

31
32
33
34
35
36
37
38
39
    type: idScalar,
    description:
      'Unique identifier for creating/updating a RiskEvidenceSynthesis record.',
  },
  resource: {
    type: new GraphQLNonNull(RiskEvidenceSynthesisInput),
    description: 'RiskEvidenceSynthesis Information for the record.',
  },
};
fork icon3
star icon14
watch icon3

+ 3 other calls in file

12
13
14
15
16
17
18
19
20
21
});
const QuoteCreateType = new GraphQLInputObjectType({
  name: 'QuoteCreateType',
  type: QuoteType,
  fields: {
    quote: { type: new GraphQLNonNull(GraphQLString) }
  }
});

const QuoteUpdateType = new GraphQLInputObjectType({
fork icon1
star icon5
watch icon2

+ 13 other calls in file

23
24
25
26
27
28
29
30
31
32
33
`;


const fixed = `
const { GraphQLNonNull } = require("graphql");
const fixedFields = [
  { id: { type: new GraphQLNonNull(require("graphql").GraphQLID), ...require("graphql-relay").globalIdField() } },
  { clearID: {} },
  { sourceSystem: {} },
  { loadDate: {} },
  { updateDate: {} },
fork icon0
star icon1
watch icon1

282
283
284
285
286
287
288
289
290
291
// submitted on updates
if (field.nullable === false &&
    !field.defaultValue &&
    !constants_1.GENERATE_SPECIAL.some((flag) => field.special.includes(flag)) &&
    action !== 'update') {
    type = new graphql_1.GraphQLNonNull(type);
}
if (collection.primary === field.field) {
    if (!field.defaultValue && !field.special.includes('uuid') && action === 'create')
        type = new graphql_1.GraphQLNonNull(graphql_1.GraphQLID);
fork icon0
star icon0
watch icon1

+ 3138 other calls in file

129
130
131
132
133
134
135
136
137
138
if (
  Object.keys(field).toString() === 'id' ||
  collumn.type.name === 'ID' ||
  Object.keys(field).toString() === 'globalId'
) {
  preField = { ...preField, type: new GraphQLNonNull(GraphQLID), ...globalIdField() };
} else {
  const fieldYAML = tableTypeFound.fields.find((tableTypeYAML) => tableTypeYAML.name === Object.keys(field).toString());
  preField = parseFieldType(fieldYAML, preField);
}
fork icon0
star icon0
watch icon1

+ 38 other calls in file

36
37
38
39
40
41
42
43
44
45
password: { type: GraphQLNonNull(GraphQLString) },
sex: { type: GraphQLNonNull(GraphQLString) },
reference: { type: GraphQLNonNull(GraphQLString) },
userType: { type: GraphQLNonNull(GraphQLString) },
userLevel: { type: GraphQLNonNull(GraphQLString) },
membership: { type: GraphQLNonNull(GraphQLBoolean) },
verified: { type: GraphQLNonNull(GraphQLBoolean) },
coupons: { type: GraphQLList(InputUserCouponType) },
preferences: { type: GraphQLList(InputUserPreferenceType) },
guideDescription: { type: GraphQLString },
fork icon0
star icon0
watch icon0

+ 99 other calls in file

2
3
4
5
6
7
8
9
10
11

global.__base = path.normalize(__dirname + '/..');
global.GraphqlSchema = global.GraphQLSchema = graphql.GraphQLSchema;
global.GraphqlObjectType = global.GraphQLObjectType = graphql.GraphQLObjectType;
global.GraphqlList = global.GraphQLList = graphql.GraphQLList;
global.GraphqlNonNull = global.GraphQLNonNull = graphql.GraphQLNonNull;
global.GraphqlUnionType = global.GraphQLUnionType = graphql.GraphQLUnionType;
global.GraphqlInterfaceType = global.GraphQLInterfaceType = graphql.GraphQLInterfaceType;
global.GraphqlEnumType = global.GraphQLEnumType = graphql.GraphQLEnumType;
global.GraphqlInt = global.GraphQLInt = graphql.GraphQLInt;
fork icon0
star icon0
watch icon5

74
75
76
77
78
79
80
81
82
83
addClient: {
    type: ClientType,
    args: {
        name: { type: GraphQLNonNull(GraphQLString) },
        email: { type: GraphQLNonNull(GraphQLString) },
        phone: { type: GraphQLNonNull(GraphQLString) },
    },
    resolve(parent, args) {
        const client = new Client({
            name: args.name,
fork icon0
star icon0
watch icon0

+ 8 other calls in file

31
32
33
34
35
36
37
38
39
40
41
}


const deleteEvent = {
    type: EventType,
    args: {
        eventDate: { type: GraphQLNonNull(GraphQLString) },
        eventTrip: { type: GraphQLNonNull(GraphQLString) }
    },
    async resolve(_, { eventDate, eventTrip }, { verifiedUser }) {
        if (!verifiedUser) throw new Error("Debes iniciar sesion para realizar esta accion");
fork icon0
star icon0
watch icon0

+ 7 other calls in file

94
95
96
97
98
99
100
101
102
103
},
//delete client 
deleteClient: {
    type: ClientType,
    args: {
        id: { type: GraphQLNonNull(GraphQLID) }
    },
    resolve(parent, args) {
        return Client.findByIdAndRemove(args.id)
    }
fork icon0
star icon0
watch icon0

+ 19 other calls in file

313
314
315
316
317
318
319
320
321
322
// note the GraphQLNonNull and GraphQLList constructors are incorrectly
// not generic over their inner type which is why we have to use as
// (the classes are generic but not the constructors)
function getTypeForField(originalType) {
  if (originalType instanceof graphql.GraphQLNonNull) {
    return new graphql.GraphQLNonNull(getTypeForField(originalType.ofType));
  }
  if (originalType instanceof graphql.GraphQLList) {
    return new graphql.GraphQLList(getTypeForField(originalType.ofType));
  }
fork icon0
star icon0
watch icon1

+ 8 other calls in file