/** * Builds the schema * * @return the built schema */ public GraphQLSchema build() { assertNotNull(additionalTypes, "additionalTypes can't be null"); assertNotNull(additionalDirectives, "additionalDirectives can't be null"); // grab the legacy code things from types final GraphQLSchema tempSchema = new GraphQLSchema(queryType, mutationType, subscriptionType, additionalTypes, additionalDirectives, codeRegistry); codeRegistry = codeRegistry.transform(codeRegistryBuilder -> schemaUtil.extractCodeFromTypes(codeRegistryBuilder, tempSchema)); GraphQLSchema graphQLSchema = new GraphQLSchema(tempSchema, codeRegistry); schemaUtil.replaceTypeReferences(graphQLSchema); Collection<SchemaValidationError> errors = new SchemaValidator().validateSchema(graphQLSchema); if (errors.size() > 0) { throw new InvalidSchemaException(errors); } return graphQLSchema; } }
var YourMutationSchema = new GraphQLSchema({ query: new GraphQLObjectType({ // ... QueryType Schema }), mutation: new GraphQLObjectType({ name: 'MutationRoot', fields: { uploadFile: { type: UploadedFileType, resolve(rootValue) { // Access file MIME multipart using const _file = rootValue.request.file; // ... Do something with file } } } }) });
/** * Builds the schema * * @return the built schema */ public GraphQLSchema build() { assertNotNull(additionalTypes, "additionalTypes can't be null"); assertNotNull(additionalDirectives, "additionalDirectives can't be null"); // grab the legacy code things from types final GraphQLSchema tempSchema = new GraphQLSchema(queryType, mutationType, subscriptionType, additionalTypes, additionalDirectives, codeRegistry); codeRegistry = codeRegistry.transform(codeRegistryBuilder -> schemaUtil.extractCodeFromTypes(codeRegistryBuilder, tempSchema)); GraphQLSchema graphQLSchema = new GraphQLSchema(tempSchema, codeRegistry); schemaUtil.replaceTypeReferences(graphQLSchema); Collection<SchemaValidationError> errors = new SchemaValidator().validateSchema(graphQLSchema); if (errors.size() > 0) { throw new InvalidSchemaException(errors); } return graphQLSchema; } }