100% found this document useful (7 votes)
79 views

Fullstack GraphQL The Complete Guide To Writing GraphQL Servers and Clients With TypeScript Gaetano Checinskil 2024 Scribd Download

Complete

Uploaded by

qrisdiiels43
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (7 votes)
79 views

Fullstack GraphQL The Complete Guide To Writing GraphQL Servers and Clients With TypeScript Gaetano Checinskil 2024 Scribd Download

Complete

Uploaded by

qrisdiiels43
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Download the full version of the textbook now at textbookfull.

com

Fullstack GraphQL The Complete Guide to


Writing GraphQL Servers and Clients with
TypeScript Gaetano Checinskil

https://textbookfull.com/product/fullstack-
graphql-the-complete-guide-to-writing-graphql-
servers-and-clients-with-typescript-gaetano-
checinskil/

Explore and download more textbook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Fullstack GraphQL The Complete Guide to Writing GraphQL


Servers and Clients with TypeScript Gaetano Checinskil Roy
Derks Ed Nate Murray
https://textbookfull.com/product/fullstack-graphql-the-complete-guide-
to-writing-graphql-servers-and-clients-with-typescript-gaetano-
checinskil-roy-derks-ed-nate-murray/
textbookfull.com

FullStack React with TypeScript Learn Pro Patterns for


Hooks Testing Redux SSR and GraphQL Revision r11 Maksim
Ivanov
https://textbookfull.com/product/fullstack-react-with-typescript-
learn-pro-patterns-for-hooks-testing-redux-ssr-and-graphql-
revision-r11-maksim-ivanov/
textbookfull.com

Beginning GraphQL with React NodeJS and Apollo Greg Lim

https://textbookfull.com/product/beginning-graphql-with-react-nodejs-
and-apollo-greg-lim/

textbookfull.com

Health Policy Analysis An Interdisciplinary Approach


Curtis P. Mclaughlin

https://textbookfull.com/product/health-policy-analysis-an-
interdisciplinary-approach-curtis-p-mclaughlin/

textbookfull.com
Advances in Clinical Chemistry 75 1st Edition Gregory S.
Makowski (Eds.)

https://textbookfull.com/product/advances-in-clinical-
chemistry-75-1st-edition-gregory-s-makowski-eds/

textbookfull.com

Introduction to Mineralogy and Petrology 2nd Edition


Swapan Kumar Haldar

https://textbookfull.com/product/introduction-to-mineralogy-and-
petrology-2nd-edition-swapan-kumar-haldar/

textbookfull.com

Agriculturally Important Fungi for Sustainable Agriculture


Volume 1 Perspective for Diversity and Crop Productivity
Ajar Nath Yadav
https://textbookfull.com/product/agriculturally-important-fungi-for-
sustainable-agriculture-volume-1-perspective-for-diversity-and-crop-
productivity-ajar-nath-yadav/
textbookfull.com

Evidence-Based Practice for Nursing and Healthcare Quality


Improvement 1st Edition Geri Lobiondo-Wood

https://textbookfull.com/product/evidence-based-practice-for-nursing-
and-healthcare-quality-improvement-1st-edition-geri-lobiondo-wood/

textbookfull.com

Battlefield Emotions 1500-1800: Practices, Experience,


Imagination 1st Edition Erika Kuijpers

https://textbookfull.com/product/battlefield-
emotions-1500-1800-practices-experience-imagination-1st-edition-erika-
kuijpers/
textbookfull.com
Statistics and Analysis of Scientific Data 2nd Edition
Massimiliano Bonamente (Auth.)

https://textbookfull.com/product/statistics-and-analysis-of-
scientific-data-2nd-edition-massimiliano-bonamente-auth/

textbookfull.com
Fullstack GraphQL
The Complete Guide to Building GraphQL Clients and Servers

Written by Gaetano Checinski and Roy Derks


Edited by Nate Murray

© 2020 newline

All rights reserved. No portion of the book manuscript may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means beyond the number of purchased copies,
except for a single backup or archival copy. The code may be used freely in your projects,
commercial or otherwise.

The authors and publisher have taken care in preparation of this book, but make no expressed
or implied warranty of any kind and assume no responsibility for errors or omissions. No
liability is assumed for incidental or consequential damagers in connection with or arising out
of the use of the information or programs container herein.

Published by newline
Contents

What to Expect from this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
What is GraphQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Why GraphQL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Usage driven and Intuitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Self-descriptive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Other advantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Join Our Discord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Hello GraphQL - GraphiQL and Github’s GraphQL Playground . . . . . . . 11


Enter GraphiQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Our First Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Named Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Multiple Queries and Renaming Result fields . . . . . . . . . . . . . . . . . . 24
Fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Union Types and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Mutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
GraphQL queries over HTTP - fetching with fetch and curl . . . . . . . . 37
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Hello GraphQL from Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39


A GraphQL Hello World from Node . . . . . . . . . . . . . . . . . . . . . . . 39
Making Changes with Mutations . . . . . . . . . . . . . . . . . . . . . . . . . 41
CONTENTS

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Hello GraphQL in the Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43


A GraphQL Hello World from Localhost . . . . . . . . . . . . . . . . . . . . 43
Putting the Query in the App . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Creating a Custom Hook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Making Updates with Mutations . . . . . . . . . . . . . . . . . . . . . . . . . 49
Handling User Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Picking a GraphQL Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54


GraphQL is just JSON over HTTP (well, usually) . . . . . . . . . . . . . . . 54
Why You Might Want a Dedicated GraphQL Client . . . . . . . . . . . . . . 55
So What Are The Options? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
graphql-request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
urql . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Relay Modern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Apollo Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
What to Choose? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

The Basics of Apollo Client and React . . . . . . . . . . . . . . . . . . . . . . . . 62


Apollo Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Getting Hooked on useQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Getting hooked on useMutation . . . . . . . . . . . . . . . . . . . . . . . . . . 66
How to use Apollo Client across your app . . . . . . . . . . . . . . . . . . . . 67
ApolloClient and Testing Components . . . . . . . . . . . . . . . . . . . . . . 67
Remember . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Building a TypeSafe GraphQL React Client App - Part 1 . . . . . . . . . . . . 72


What are we building? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Tooling and Project Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
TypeScript and GraphQL Types - There is a difference . . . . . . . . . . . . 75
Generating Types with graphql-codegen . . . . . . . . . . . . . . . . . . . . . 76
Generating Types for Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Generating Helper Functions for Apollo . . . . . . . . . . . . . . . . . . . . . 79
Building the Issue Finder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Creating the Search Component . . . . . . . . . . . . . . . . . . . . . . . . . . 83
CONTENTS

Visualizing Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Pagination with cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Tracking our cursorState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

Building a TypeSafe GraphQL React Client App - Part 2 . . . . . . . . . . . . 93


What are we building? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Loading Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Mutations - Modifying Existing Data . . . . . . . . . . . . . . . . . . . . . . . 103
Mutations - Creating New Data . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Refetching Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Manually Updating the Apollo Cache . . . . . . . . . . . . . . . . . . . . . . 110
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Your First GraphQL Server with Apollo Server . . . . . . . . . . . . . . . . . . 115


Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
The Obligatory Boilerplate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Mocking the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Resolvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Chaining Resolvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Passing Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

Using GraphQL Servers with A Database . . . . . . . . . . . . . . . . . . . . . 137


Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Using GraphQL with a Database . . . . . . . . . . . . . . . . . . . . . . . . . 138
Queries with pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Writing Mutation Resolvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

Caching and Batching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159


Optimized queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
CONTENTS

Batching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Cost computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

Authentication and Authorization in GraphQL . . . . . . . . . . . . . . . . . . 178


JWT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Resolver Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Context Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Schema Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Code First GraphQL with TypeORM and TypeGraphQL . . . . . . . . . . . . 205


TypeGraphQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Implementing Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Using Context in a Resolver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
TypeORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Authorization with TypeGraphQL . . . . . . . . . . . . . . . . . . . . . . . . 221
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
More on TypeGraphQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

Where to Go From Here? Advanced GraphQL . . . . . . . . . . . . . . . . . . 224


What did you think? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Awesome GraphQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Say Hello . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
What to Expect from this book
Fullstack GraphQL will give you a use-case driven, hands-on introduction to the
GraphQL ecosystem. This book intends to present GraphQL to you in a problem-
oriented and pragmatic fashion - and ultimately give you the confidence to use
GraphQL in your everyday full-stack challenges.
This book shows both theoretical and conceptual aspects of GraphQL, including code
examples book using React, Node.js, and Typescript to showcase how to use GraphQL
to generate and render data.
The structure of this book is loosely inspired by the workflow of a Fullstack Engineer
and will reveal GraphQL specific concepts through the life-cycle of a real-world app.
GraphQL is an opinionated query language, with an ecosystem that will change the
way you write frontend and backend solutions.
Motivation
What is GraphQL
“A query language for your API” - The GraphQL Foundation

GraphQL is a specification to query APIs, and provides a server-side runtime to


execute those queries using a strongly typed system based on your data. Based on
the data model, GraphQL can return you the data in exactly the same format as you
request it in. It can be used language and framework agnostic, and connected to any
database or storage engine.
In 2015 the specification for GraphQL was first publicly shared with the world
by Facebook, after it was developed internally. To guarantee the continuation of
GraphQL by the community, the project was moved into the GraphQL Foundation
in 2019.

Why GraphQL?
Before we present you the problems that inspired the creation of GraphQL, let us
have a look at this famous quote:

“A language that doesn’t affect the way you think about programming, is
not worth knowing.” - Alan Perlis

GraphQL changed the way how data was transferred between applications in a fixed
format, to a new approach to dynamically transfer data between a “frontend” and
a “backend”. This allowed Facebook to tackle many problems with data fetching for
mobile applications, without having to create a new REST API for every application.
Motivation 3

As you will work through this book, we hope you won’t just add GraphQL to your
toolbox, but also develop a new way of thinking about data models, APIs and full-
stack development.
The ecosystem surrounding GraphQL gives you the tools to start building and
querying APIs, that are:
Usage Driven It encourages users to define queries that specify what data to fetch in
a granular way.
Intuitive GraphQL delivers you only the data that you request, in the exact same
format that you requested it in
Self-descriptive GraphQLs schemas are strongly typed and define a strict contract
between a query and its response. It makes GraphQL responses very predictable and
also suitable for documentation.
GraphQL embodies many lessons learned from API design that enforces several
best practices into one solution. As engineers, we’re facing the challenge of not just
building systems, but also evolving these systems to fit new requirements.

Usage driven and Intuitive


REST APIs were designed with specific use-cases in mind, making the development
of “backend” and “frontend” loosely coupled or even independent.
The design of a REST API is often directly linked to the data model of the database
that it’s reading and mutating, making it a mere abstraction layer over this database.
Motivation 4

In this example, we see a wire-frame of posts, how the underlying REST API, and a
direct comparison with GraphQL.
When the REST API was created to serve the UI of a specific frontend application, the
design of the REST API (and consequentially the data model of the database) should
always match that UI. When the UI changes, the data flow and the data model of
that database no longer match.
This can lead to a problem that often arises when you’re used to working with REST
APIs, that is called the n+1 problem. If you need to query multiple endpoints to collect
enough data to render a page, then you are already facing the n+1 problem.

The n+1 problem


This problem describes the cascade of independent requests triggered by the lack of
data in one response.
For the Developer Experience (DX) and performance reasons, it’s therefore often
desirable to fetch all of the data we need in one HTTP request to serve the UI.
However, as your application grows in size, you find that you often end up creating
a unique REST endpoint for every change in either the UI or the data model of the
database.
For example, you created an endpoint that returns user information. This information
was at first used to display a profile page but is also used to display a short overview
of a user profile. Even later, you even use this information to display the user’s avatar
somewhere else.
This raises the following questions: 1) Should the backend grow with the require-
ments of each of it’s clients? 2) Should the backend endpoints be changed as the
client’s requirements change? 3) Should the backend endpoints take configuration
parameters to suit every client?
As we think through each of those options, we will notice that they all have their
pros and cons.
Building a custom endpoint for a specific client allows you to fine-tune the backend
for maximal performance. However, this will increase the number of endpoints to
maintain.
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Motivation 5

Constantly adapting one endpoint to fit new requirements won’t suffer the same
issue but it will introduce a host of other questions: - How do we migrate old clients
to the newer version? - Will we need to support both versions?
The last option combines the best of both worlds but introduces a level of indirection
and requires a custom implementation.
GraphQL implements and standardizes this approach, as you’ll discover in the first
chapters of this book.
As you see, in GraphQL there is not only an intuitive mapping between queries and
data but also it encodes the domain-specific language of your application.

Self-descriptive
REST is very minimalistic and does not enforce any types or schemas, and as a result,
validation of input and output and documentation are complementary aspects of a
REST API.
Consequently, validation and documentation is a maintenance burden. That is a
potential source of bugs if the proper discipline isn’t exhibited at all times. GraphQL
has been designed with this in mind, leading to a more robust API and less overhead
for developers.
All this is based on a GraphQL schema, a strongly typed and object-orientated
representation of the data model for the application. The schema is used to both
validate the requests and statically check the types of the operations and responses.
Being schema-driven also has an interesting side-effect, as the schema is always tied
to the operations and responses and as a result, the schema is never out of date. We
can always generate up-to-date documentation.

Other advantages
GraphQL provides many other advantages over a “traditional” approach for handling
data flows between applications, as you’ll discover in this book
Motivation 6

Prerequisites
In this book we assumed that you have at least the following skills:

• basic JavaScript knowledge (working with functions, objects, and arrays)


• a basic React understanding (at least general idea of component based approach)
• some command line skill (you know how to run a command in terminal)

Here we mostly focus on specifics of using GraphQL with Node.js, TypeScript, and
React.
The instructions we give in this book are very detailed, so if you lack some of the
listed skills - you can still follow along with the tutorials and be just fine.

Running Code Examples


Each section has an example app shipped with it. You can download code examples
from the same place where you purchased this book.
If you have any trouble finding or downloading the code examples, email us at
[email protected]¹.
In the beginning of each section you will find instructions of how to run the example
app. In order to run the examples you need a terminal app and NodeJS installed on
your machine.
Make sure you have NodeJS installed. Run node -v, it should output your current
NodeJS version:

$ node -v
v10.19.0

Anything between Node 10 through 14+ should be fine.

Here are instructions for installing NodeJS on different systems:


¹mailto:[email protected]
Motivation 7

Windows

To work with examples in this book we recommend installing Cmder² as a terminal


application.
We recommend installing node using nvm-windows³. Follow the installation instruc-
tions on the Github page.
Then run nvm to get the latest LTS version of NodeJS:

nvm install --lts

It will install the latest available LTS version.

Mac

Mac OS has a Terminal app installed by default. To launch it toggle Spotlight, search
for terminal and press Enter.
Run the following command to install nvm⁴:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/inst\


all.sh | bash

Then run nvm to get the latest LTS version of NodeJS:

nvm install --lts

This command will also set the latest LTS version as default, so you should be all set.
If you face any issues follow the troubleshooting guide for Mac OS⁵.

Linux

Most Linux distributions come with some terminal app provided by default. If you
use Linux - you probably know how to launch terminal app.
Run the following command to install nvm⁶:
²https://cmder.net/
³https://github.com/coreybutler/nvm-windows
⁴https://github.com/nvm-sh/nvm
⁵https://github.com/nvm-sh/nvm#troubleshooting-on-macos
⁶https://github.com/nvm-sh/nvm
Motivation 8

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/inst\


all.sh | bash

Then run nvm to get the latest LTS version of NodeJS:

nvm install --lts

In case of problems with installation follow the troubleshooting guide for Linux⁷.

Code Blocks And Context

Code Block Numbering

In this book, we build example applications in steps. Every time we achieve a


runnable state - we put it in a separate step folder.

1 01-first-app/
2 ├── step1
3 ├── step2
4 ├── step3
5 ... // other steps

If at some point in the chapter we achieve the state that we can run - we will tell you
how to run the version of the app from the particular step.
Some files in that folders can have numbered suffixes with *.example word in the
end:

1 src/AddNewItem0.tsx.example

If you see this - it means that we are building up to something bigger. You can jump
to the file with same name but without suffix to see a completed version of it.
Here the completed file would be src/AddNewItem.tsx.
⁷https://github.com/nvm-sh/nvm#troubleshooting-on-linux
Motivation 9

Reporting Issues
We’ve done our best to make sure that our instructions are correct and code samples
don’t contain errors. There is still a chance that you will encounter problems.
If you find a place where a concept isn’t clear or you find an inaccuracy in our
explanations or a bug in our code, you should leave a comment inline on newline.co.

If you are reading this via PDF, did you know you can read all of newline’s
books online? You can either sync your purchases from your Gumroad
account or read them via newline Pro⁸

You can also try emailing us⁹


In either case, we want to make sure that our book is precise and clear.

Getting Help
If you have any problems working through the code examples in this book, you
should try:

• leaving a comment
• joining our Discord and asking or
• send us an email.

To make it easier for us to help you include the following information:

• What revision of the book are you referring to?


• What operating system are you on? (e.g. Mac OS X 10.13.2, Windows 95)
• Which chapter and which example project are you on?
• What were you trying to accomplish?
• What have you tried already?
• What output did you expect?
• What actually happened? (Including relevant log output.)

Ideally also provide a link to a git repository where we can reproduce an issue you
are having.
⁸https://newline.co/pricing
⁹mailto:[email protected]
Motivation 10

Join Our Discord


We have a community Discord which you can join here¹⁰ and join the #graphql
channel
¹⁰https://newline.co/discord
Hello GraphQL - GraphiQL and
Github’s GraphQL Playground
In this chapter, we will be getting familiar with GraphQL by using Github’s GraphQL
explorer.
To get the most out of this chapter, we suggest you head over to The Github API
Explorer¹¹ and follow along.
Below, we’ll present code examples will guide you through GraphQL’s intuitive, rich
query language.
After this chapter you will be able to:

• Understand GraphQL schemas


• Read and write GraphQL Queries
• Explore APIs using the GraphQL Playground
• Send queries using fetch and curl

Enter GraphiQL
Once you navigate to The Github API Explorer and Sign-In you’ll be welcomed with
the online IDE that looks like this:
¹¹https://developer.github.com/v4/explorer/
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 12

This is one of the most useful developer tools GraphQL offers and is known as
GraphiQL - notice the i in the middle of that previous word. It stands for “interactive”
and it’s the GraphQL explorer.
It’s your first stop when developing and exploring any GraphQL endpoint. GraphiQL
provides an IDE experience with autocompletion, documentation and a simple query
editor.

1. it syntax checks your queries


2. you can run queries and see the results
3. you can explore the types as you work

The documentation for exploring the types might be a little intimidating at


first, but don’t worry, we’ll walk through how to make sense of it.
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 13

Our First Query


GraphQL queries look a little like JSON, here’s our first query:

query {
viewer {
login
}
}

Above you’ll see this isn’t quite JSON though, we don’t have any values! (Only keys).
The response, however is in JSON. Let’s take a look:
Here’s the response for our query above:

{
"data": {
"viewer": {
"login": "nikhedonia",
}
}
}

Notice that the shape of our request matches the shape of our response. And GraphQL
fills in the values for the keys that we requested. This shape-matching is a powerful
feature of GraphQL. But another powerful feature of GraphQL is it’s type system.
Let’s investigate what a viewer is and open the Documentation by hitting the “Docs”
button on the right-hand side.
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 14

In GraphQL every field has a type associated and can be inspected in GraphiQL by
clicking on it.
If you click on “Query” then you’ll see all available fields that you can query - and
among them you’ll find viewer: User!

In English this means “the field viewer returns a User” and the exclamation mark
means it will never return null.
The field user on the other hand is a function that takes a login of type string and
returns a User but may return null if the User doesn’t exist.
I think this is a noteworthy language choice: all field declarations are considered
optional by default.
The documentation is generated directly from the schema. The GraphQL schema
roughly looks like this:
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 15

# A user is an individual's account on GitHub ...


type User {
login: String! # login is of type String. ! means it is never null
email: String # email might be null
# more fields...
}

type Query {
user(login: String!): User
viewer: User # The currently authenticated user
# more fields...
}

Above we have a minimal schema with two user-defined types: User and Query. This
is how to read it:
User has two fields: login and email, both of type String.

Because login is of type String! with an exclamation mark - it is may never be null.
However, email may be null.
Query is a type with special importance: it marks the root and describes the starting
point of any query. (Queries read data, but to write data we use what is called
mutations - more on that below).

This particular schema also exposes viewer as a field of Query, allowing


us to reach into the data it holds. The viewer parameter here returns a
User as well, but notice that there is no login parameter. That is because
viewer returns the current authenticated user. More on this below.

Let’s try to find users by their login:


Hello GraphQL - GraphiQL and Github’s GraphQL Playground 16

query {
user(login: "leebyron") {
login
name
bio
}
}

This query is asking for the user that has the login of leebyron and requests the
fields login, name and bio. It returns:

{
"data": {
"user": {
"login": "leebyron",
"name": "Lee Byron",
"bio": "I make things @robinhood, previously @facebook."
}
}
}

Lee Byron is one of the creators of GraphQL

Try putting in your own Github username and see what comes out!
If we pass a login that is not associated with any user (eg. login: "") then it will
return null:
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 17

{
"data": {
"user": null
},
"errors": [
{
"type": "NOT_FOUND",
"path": [
"user"
],
"locations": [
{
"line": 7,
"column": 3
}
],
"message": "Could not resolve to a User with the login of ''."
}
]
}

Even more, the response contains also a descriptive error message with location
information and error type.
This design allows GraphQL to return a valid query response even if only partial
results - or no results - are available. We can query multiple fields and the server
will return data even if some fields can’t be “resolved”. For example, we can ask for
viewer in the same query:
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 18

query {
viewer {
login
}
user(login: "") {
login
name
bio
}
}

Which will return viewer even though no user could be found:

{
"data": {
"viewer": {
"login": "nikhedonia"
},
"user": null
},
"errors": [
# ...
]
}

Named Queries
It is highly recommended to name your queries. Although the name is optional, it
is important for code generators and clients. Most clients use the name for caching
purposes.

For example, Apollo Client, a popular JavaScript client for GraphQL that
we talk more about in future chapters, uses named queries. Also, tools like
TypeScript type generation also uses named queries.
So while names are technically optional, it’s a good idea to use them.
Hello GraphQL - GraphiQL and Github’s GraphQL Playground 19

So lets give our previous query a name:

query getUser {
user(login: "leebryon") {
login
name
bio
}
}

The name goes right after query keyword - so above, getUser is the query name.
Note that we could name our query pretty much whatever we want. Instead of
getUser, we could have named it getLeeBryon. The query name isn’t “special” insofar
as we can pick what we want.
However, the user field is “special” in that it’s defined by the schema or GraphQL
server. For example the following would not work:

query getUser {
# this wont work, example of an invalid field `getUser`
getUser(login: "leebryon") {
login
name
bio
}
}

Why does this not work? Because the inner getUser is not defined by the schema.
More specifically, remember that our schema looks like this:
Random documents with unrelated
content Scribd suggests to you:
the twelfth proposition. But we ask them: “Have you observed a
complete revolution of a millstone? Each point in the extreme
circumference of the stone describes a large circle in the very same
time in which a point nearer the centre describes a small circle; the
velocity of the outer circle is therefore greater than that of the inner
circle. You cannot say that the motion of the latter was interrupted
by more moments of rest; for the whole moving body, i.e., the
millstone, is one coherent body.” They reply, “During the circular
motion, the parts of the millstone separate from each other, and the
moments of rest interrupting the motion of the portions nearer the
centre are more than those which interrupt the motion of the outer
portions.” We ask again, “How is it that the millstone, which we
perceive as one body, and which cannot be easily broken, even with
a hammer, resolves into its atoms when it moves, and becomes
again one coherent body, returning to its previous state as soon as it
comes to rest, while no one is able to notice the breaking up [of the
stone]?” Again their reply is based on the twelfth proposition, which
is to the effect that the perception of the senses cannot be trusted,
and thus only the evidence of the intellect is admissible. Do not
imagine that you have seen in the foregoing example the most
absurd of the inferences which may be drawn from these three
propositions: the proposition relating to the existence of a vacuum
leads to more preposterous and extravagant conclusions. Nor must
you suppose that the aforegoing theory concerning motion is less
irrational than the proposition resulting from this theory, that the
diagonal of a square is equal to one of its sides, and some of the
Mutakallemim go so far as to declare that the square is not a thing
of real existence. In short, the adoption of the first proposition
would be tantamount to the rejection of all that has been proved in
Geometry. The propositions in Geometry would, in this respect, be
divided into two classes: some would be absolutely rejected; e.g.,
those which relate to properties of the incommensurability and the
commensurability of lines and planes, to rational and irrational lines,
and all other propositions contained in the tenth book of Euclid, and
in similar works. Other propositions would appear to be only partially
correct; e.g., the solution of the problem to divide a line into two
equal parts, if the line consists of an odd number of atoms;
according to the theory of the Mutakallemim such a line cannot be
bisected. Furthermore, in the well-known book of problems by the
sons of Shakir are contained more than a hundred problems, all
solved and practically demonstrated; but if there really were a
vacuum, not one of these problems could be solved, and many of
the waterworks [described in that book] could not have been
constructed. The refutation of such propositions is a mere waste of
time. I will now proceed to treat of the other propositions mentioned
above. [123]

Fourth Proposition.

“The accidents of things have real existence; they are elements


superadded to the substance itself, and no material thing can be
without them.” Had this proposition been left by the Mutakallemim in
this form it would have been correct, simple, dear, and indisputable.
They have, however, gone further, asserting that a substance which
has not the attribute of life, must necessarily have that of death; for
it must always have one of two contrasting properties. According to
their opinion, colour, taste, motion or rest, combination or
separation, etc., can be predicated of all substances, and, if a
substance have the attribute of life, it must at the same time
possess such other kinds of accidents, as wisdom or folly, freewill or
the reverse, power or weakness, perception or any of its opposites,
and, in short, the substance must have the one or the other of all
correlative accidents appertaining to a living being.

Fifth Proposition.
“The atom is fully provided with all these foregoing accidents, and
cannot exist if any be wanting.” The meaning of the proposition is
this: The Mutakallemim say that each of the atoms created by God
must have accidents, such as colour, smell, motion, or rest, except
the accident of quantity: for according to their opinion an atom has
no magnitude; and they do not designate quantity as an accident,
nor do they apply to it the laws of accidents. In accordance with this
proposition, they do not say, when an accident is noticed in a body,
that it is peculiar to the body as such, but that it exists in each of
the atoms which form the constituent elements of that body. E.g.,
take a heap of snow; the whiteness does not exist in that heap as a
whole, but each atom of the snow is white, and therefore the
aggregate of these atoms is likewise white. Similarly they say that
when a body moves each atom of it moves, and thus the whole body
is in motion. Life likewise exists, according to their view, in each
atom of a living body. The same is the case according to their
opinion with the senses; in each atom of the aggregate they notice
the faculty of perception. Life, sensation, intellect and wisdom are
considered by them as accidents, like blackness and whiteness, as
will be shown in the further discussion of their theory.

Concerning the soul, they do not agree. The view most predominant
among them is the following:—The soul is an accident existing in one
of the atoms of which, e.g., man is composed; the aggregate is
called a being endowed with a soul, in so far as it includes that
atom. Others are of opinion that the soul is composed of ethereal
atoms, which have a peculiar faculty by virtue of which they
constitute the soul, and that these atoms are mixed with the atoms
of the body. Consequently they maintain that the soul is an accident.

As to the intellect, I found that all of them agreed in considering it to


be an accident joined to one of the atoms which constitute the
whole of the intelligent being. But there is a confusion among them
about knowledge; they are uncertain whether it is an accident to
each of the atoms which form the knowing aggregate, or whether it
belongs only to one atom. Both views can be disproved by a reductio
ad absurdum, when the following facts are pointed out to them.
Generally metals and stones have a peculiar colour, [124]which is
strongly pronounced, but disappears when they are pulverised.
Vitriol, which is intensely green, becomes white dust when pounded;
this shows that that accident exists only in the aggregate, not in the
atoms. This fact is more striking in the following instance: when
parts of a living being are cut off they cease to live, a proof that the
accident [of life] belongs to the aggregate of the living being, not to
each atom. In order to meet this objection they say that the accident
is of no duration, but is constantly renewed. In discussing the next
proposition I shall explain their view on this subject.

Sixth Proposition.

“The accidents do not exist during two time-atoms.”—The sense of


the proposition is this: They believe that God creates a substance,
and simultaneously its accidents; that the Creator is incapable of
creating a substance devoid of an accident, for that is impossible;
that the essential characteristic of an accident is its incapability of
enduring for two periods, for two time-atoms; that immediately after
its creation it is utterly destroyed, and another accident of the same
kind is created; this again is destroyed and a third accident of the
same kind is created, and so on, so long as God is pleased to
preserve [in that substance] this kind of accident; but He can at His
will create in the same substance an accident of a different kind, and
if He were to discontinue the creation and not produce a new
accident, that substance would at once cease to exist. This is one of
the opinions held by the Mutakallemim; it has been accepted by
most of them, and it is the so-called “theory of the creation of the
accidents.” Some of them, however, and they belong to the sect of
the Muʻtazilah, say that there are accidents which endure for a
certain period, and other accidents which do not endure for two
atoms of time; they do not follow a fixed principle in deciding what
class of accidents has and what class has not a certain duration. The
object of this proposition is to oppose the theory that there exists a
natural force from which each body derives its peculiar properties.
They prefer to assume that God himself creates these properties
without the intervention of a natural force or of any other agency: a
theory which implies that no accident can have any duration. For
suppose that certain accidents could endure for a certain period and
then cease to exist, the question would naturally be asked, What is
the cause of that non-existence? They would not be satisfied with
the reply that God by His will brought about this non-existence, and
non-existence does not at all require any agens whatever; for as
soon as the agens leaves off acting, the product of the agens ceases
likewise to exist. This is true to some extent. Having thus chosen to
establish the theory that there does not exist any natural force upon
which the existence or non-existence of a thing depends, they were
compelled to assume that the properties of things were successively
renewed. When God desires to deprive a thing of its existence, He,
according to some of the Mutakallemim, discontinues the creation of
its accidents, and eo ipso the body ceases to exist. Others, however,
say that if it pleased the Almighty to destroy the world, He would
create the accident of destruction, which would be without any
substratum. The destruction of the Universe would be the correlative
accident to that of existence.—In accordance with this [sixth]
proposition they say, that the [125]cloth which according to our belief
we dyed red, has not been dyed by us at all, but God created that
colour in the cloth when it came into contact with the red pigment;
we believe that colour to have penetrated into the cloth, but they
assert that this is not the case. They say that God generally acts in
such a way, that, e.g., the black colour is not created unless the
cloth is brought into contact with indigo; but this blackness, which
God creates in the instant when the cloth touches the black pigment
is of no duration, and another creation of blackness then takes
place; they further say that after the blackness is gone, He does not
create a red or green colour, but again a black colour.

According to this principle, the knowledge which we have of certain


things to-day, is not the same which we had of them yesterday; that
knowledge is gone, and another like it has been created. They
positively believe that this does take place, knowledge being an
accident. In like manner it would follow that the soul, according to
those who believe that it is an accident, is renewed each moment in
every animated being, say a hundred thousand times; for, as you
know, time is composed of time-atoms. In accordance with this
principle they assert that when man is perceived to move a pen, it is
not he who has really moved it; the motion produced in the pen is
an accident which God has created in the pen; the apparent motion
of the hand which moves the pen is likewise an accident which God
has created in the moving hand; but the creative act of God is
performed in such a manner that the motion of the hand and the
motion of the pen follow each other closely; but the hand does not
act, and is not the cause of the pen’s motion; for, as they say, an
accident cannot pass from one thing to another. Some of the
Mutakallemim accordingly contend that this white cloth, which is
coloured when put into the vessel filled with indigo, has not been
blackened by the indigo; for blackness being an attribute of indigo,
does not pass from one object to another. There does not exist any
thing to which an action could be ascribed; the real agens is God,
and He has [in the foregoing instance] created the blackness in the
substance of the cloth when it came into contact with the indigo, for
this is the method adopted by Him. In short, most of the
Mutakallemim believe that it must never be said that one thing is the
cause of another; some of them who assumed causality were
blamed for doing so. As regards, however, the acts of man their
opinions are divided. Most of them, especially the sect of the
Asha’ariyah, assume that when the pen is set in motion God has
created four accidents, none of which is the cause of any of the rest,
they are only related to each other as regards the time of their co-
existence, and have no other relation to each other. The first
accident is man’s will to move the pen, the second is man’s power to
do so, the third is the bodily motion itself, i.e., the motion of the
hand, and the fourth is the motion of the pen. They believe that
when a man has the will to do a thing and, as he believes, does it,
the will has been created for him, then the power to conform to the
will, and lastly the act itself. The act is not accomplished by the
power created in man; for, in reality, no act can be ascribed to that
power. The Muʻtazilah contend that man acts by virtue of the power
which has been created in him. Some of the Asha’ariyah assert that
the power created in man participates in the act, and is connected
with it, an opinion which has been rejected by the majority of them.
The will and the [126]power created in man, according to the
concurrent belief of the Mutakallemim, together with the act created
in him, according to some of them, are accidents without duration.
In the instance of the pen, God continually creates one motion after
the other so long as the pen is in motion; it only then ceases to
move when God has created in it the accident of rest; and so long as
the pen is at rest, God continually renews in it that accident.
Consequently in every one of these moments, i.e., of the time-
atoms, God creates some accident in every existing individual, e.g.,
in the angels, in the spheres and in other things; this creation takes
place continually and without interruption. Such is, according to their
opinion, the right interpretation of the creed that God is the causa
efficiens. But I, together with all rational persons, apply to those
theories the words, “Will you mock at Him, as you mock at man?”
for their words are indeed nothing but mockery.

Seventh Proposition.
“The absence of a property is itself a property that exists in the
body, a something superadded to its substance, an actual accident,
which is constantly renewed; as soon as it is destroyed it is
reproduced.” The reason why they hold this opinion is this: they do
not understand that rest is the absence of motion; death the
absence of life; that blindness is the absence of sight, and that all
similar negative properties are the absence of the positive
correlatives. The relation between motion and rest is, according to
their theory, the same as the relation between heat and cold,
namely, as heat and cold are two accidents found in two objects
which have the properties of heat and cold, so motion is an accident
created in the thing which moves, and rest an accident created in
the thing which rests; it does not remain in existence during two
consecutive time-atoms, as we have stated in treating of the
previous proposition. Accordingly, when a body is at rest, God has
created the rest in each atom of that body, and so long as the body
remains at rest God continually renews that property. The same,
they believe, is the case with a man’s wisdom and ignorance; the
latter is considered by them as an actual accident, which is subject
to the constant changes of destruction and creation, so long as there
remains a thing of which such a man is ignorant. Death and life are
likewise accidents, and as the Mutakallemim distinctly state, life is
constantly destroyed and renewed during the whole existence of a
living being; when God decrees its death, He creates in it the
accident of death after the accident of life, which does not continue
during two time-atoms, has ceased to exist. All this they state
clearly.

The logical consequence of this proposition is that the accident of


death created by God instantly ceases to exist, and is replaced by
another death which again is created by God; otherwise death could
not continue. Death is thus continually created in the same manner
as life is renewed every moment. But I should wish to know how
long God continues to create death in a dead body. Does He do so
whilst the form remains, or whilst one of the atoms exists? For in
each of the atoms of the body the accident of death which God
creates is produced, and there are to be found teeth of persons who
died thousands of years ago; we see that those teeth have not been
deprived of existence, and therefore the accident of death has
during all these thousands of years been renewed, and according to
the opinion [127]prevailing amongst those theorists, death was
continually replaced by death. Some of the Muʻtazilah hold that there
are cases in which the absence of a physical property is not a real
property, that weariness is the absence of strength, and ignorance
the absence of knowledge; but this cannot be said in every case of
negative properties: it cannot be said that darkness is the mere
absence of light, or that rest is the absence of motion. Some
negative properties are thus considered by them as having a real
existence, while other negative properties are considered as non-
existing, just as suits their belief. Here they proceed in the same
manner as they proceed respecting the duration of accidents, and
they contend that some accidents exist a long time, and other
accidents do not last two time-atoms. Their sole object is to fashion
the Universe according to their peculiar opinions and beliefs.

Eighth Proposition.

“There exists nothing but substance and accident, and the physical
form of things belong to the class of accidents.” It is the object of
this proposition to show that all bodies are composed of similar
atoms, as we have pointed out in explaining the first proposition.
The difference of bodies from each other is caused by the accidents,
and by nothing else. Animality, humanity, sensibility, and speech, are
denoted as accidents like blackness, whiteness, bitterness, and
sweetness, and the difference between two individuals of two
classes is the same as the difference of two individuals of the same
class. Also the body of the heaven, the body of the angels, the body
of the Divine Throne—such as it is assumed to be—the body of
anything creeping on the earth, and the body of any plant, have one
and the same substance; they only differ in the peculiarity of the
accidents, and in nothing else; the substance of all things is made
up of equal atoms.

Ninth Proposition.

“None of the accidents form the substratum of another accident; it


cannot be said, This is an accident to a thing which is itself an
accident to a substance. All accidents are directly connected with the
substance.” The Mutakallemim deny the indirect relation of the
accident to the substance, because if such a relation were assumed
it would follow that the second accident could only exist in the
substance after another accident had preceded it, a conclusion to
which they would object even with regard to some special accidents;
they prefer to show that these accidents can exist in every possible
substance, although such substance is not determined by any other
accident; for they hold that all the accidents collectively determine
the thing. They advance also another proof [in support of this
proposition], namely: The substratum which is the bearer of certain
attributes must continue to exist for a certain time; how, then, could
the accident; which—according to their opinion—does not remain in
existence for two moments, become the substratum of something
else?

Tenth Proposition.

This proposition concerns the theory of “admissibility,” which is


mentioned by the Mutakallemim, and forms the principal support of
their doctrine. Mark its purport: they observe that everything
conceived by the [128]imagination is admitted by the intellect as
possible; e.g., that the terrestrial globe should become the all-
encompassing sphere, or that this sphere should become the
terrestrial globe; reason does not find here an impossibility; or that
the sphere of fire should move towards the centre, and the sphere
of earth towards the circumference. Human intellect does not
perceive any reason why a body should be in a certain place instead
of being in another. In the same manner they say that reason admits
the possibility that an existing being should be larger or smaller than
it really is, or that it should be different in form and position from
what it really is; e.g., a man might have the height of a mountain,
might have several heads, and fly in the air; or an elephant might be
as small as an insect, or an insect as huge as an elephant. This
method of admitting possibilities is applied to the whole Universe.
Whenever they affirm that a thing belongs to this class of admitted
possibilities, they say that it can have this form, and that it is also
possible that it be found differently, and that the one form is not
more possible than the other; but they do not ask whether the
reality confirms their assumption. They say that the thing which
exists with certain constant and permanent forms, dimensions, and
properties, only follows the direction of habit, just as the king
generally rides on horseback through the streets of the city, and is
never found departing from this habit; but reason does not find it
impossible that he should walk on foot through the place; there is no
doubt that he may do so, and this possibility is fully admitted by the
intellect. Similarly, earth moves towards the centre, fire turns away
from the centre; fire causes heat, water causes cold, in accordance
with a certain habit; but it is logically not impossible that a deviation
from this habit should occur, namely, that fire should cause cold,
move downward, and still be fire; that the water should cause heat,
move upward, and still be water. On this foundation their whole
fabric is constructed. They admit, however, the impossibility of two
opposite properties coexisting at the same time in one substance.
This is impossible; reason would not admit this possibility. Again,
reason does not admit the possibility of a substance existing without
an accident, or an accident existing without a substance, a possibility
admitted by some of the Mutakallemim. It is also impossible that a
substance should become an accident, that an accident should
become a substance, or that one substance should penetrate
another. They admit that reason rejects all these things as
impossible. It is perfectly true that no notion whatever can be
formed of those things which they describe as impossible; whilst a
notion can be formed of those things which they consider as
possible. The philosophers object to this method, and say, You call a
thing impossible because it cannot be imagined, or possible because
it can be imagined; and thus you consider as possible that which is
found possible by imagination, not by the intellect, consequently you
determine that a thing is necessary, possible, or impossible in some
instances, by the aid of the imagination—not by the intellect—and in
other instances by the ordinary common sense, as Abu Nasr says in
speaking of that which the Mutakallemim call intellect. It is clear that
they describe as possible that which can be imagined, whether the
reality correspond to it or not, and as impossible that which cannot
be imagined. This proposition can only be established by the nine
aforementioned propositions, and no doubt these were exclusively
required for the support of [129]this proposition. This you will see
clearly when I shall show and explain to you some important parts
of this theory, which I shall now introduce in the form of a discussion
supposed to have taken place between a Mutakallem and a
philosopher.

The Mutakallem said to the philosopher: What is the reason that we


find the substance of iron extremely hard and strong, with a dark
colour; the substance of cream, on the other hand, extremely soft
and white? The philosopher replied as follows: All physical bodies
have two kinds of accidents: those which concern their substance,
as, e.g., the health and the illness of a man; and those which
concern their form, as, e.g., the astonishment and laughter of a
man. The substances of compound bodies differ very much in their
ultimate form, according to the difference of the forms peculiar to
each component substance. Hence the substance of iron has
become in its properties the opposite of the substance of cream, and
this difference is attended by the difference of accidents. You notice,
therefore, hardness in the one, and softness in the other: two
accidents, whose difference results from the difference which exists
in the forms of the substances; while the darkness and the
whiteness are accidents whose divergence corresponds to that of the
two substances in their ultimate condition. The Mutakallem refuted
this reply by means of his propositions, as I am now going to state:
—There does not exist a form which, as you believe, modifies the
substance, and thus causes substances to be different from each
other; this difference is exclusively effected by the accidents—
according to the theory of the Kalâm, which we mentioned in
explaining the eighth proposition. He then continued thus: There is
no difference between the substance of iron and that of cream; all
things are composed of the same kind of atoms.—We explained the
view of the Mutakallemim on this point in treating of the first
proposition, the logical consequences of which are, as we have
shown, the second and the third propositions; they further require
the twelfth proposition, in order to establish the theory of atoms.
Nor do they admit that any accidents determine the nature of a
substance, or predispose it to receive certain other accidents; for,
according to their opinion, an accident cannot be the substratum of
another accident, as we have shown in explaining the ninth
proposition; nor can it have any duration, according to the sixth
proposition. When the Mutakallemim have established all that they
wish to infer from these propositions, they arrive at the conclusion
that the component atoms of cream and of iron are alike.—The
relation of each atom to each of the accidents is the same; one atom
is not more adapted than another to receive a certain accident; and
as a certain atom is not more fitted to move than to rest, so one
atom is not more apt than another to receive the accident of life, of
reason, of sensation. It is here of no moment whether a thing
contains a larger or smaller quantity of atoms, for, according to the
view of the Mutakallemim, which we explained in treating of the fifth
proposition, every accident [of a thing] exists in each of its atoms.
All these propositions lead to the conclusion that a human being is
not better constituted to become wise than the bat, and establish
the theory of admissibility expressed in this [tenth] proposition.
Every effort was made to demonstrate this proposition, because it is
the best means for proving anything they like, as will be explained.
[130]

Note.—Mark, O reader, that if you know the nature of the soul and
its properties, and if you have a correct notion of everything which
concerns the soul, you will observe that most animals possess
imagination. As to the higher class of animals, that is, those which
have a heart, it is obvious that they have imagination. Man’s
distinction does not consist in the possession of imagination, and the
action of imagination is not the same as the action of the intellect,
but the reverse of it. For the intellect analyses and divides the
component parts of things, it forms abstract ideas of them,
represents them in their true form as well as in their causal relations,
derives from one object a great many facts, which—for the intellect
—totally differ from each other, just as two human individuals appear
different to the imagination; it distinguishes that which is the
property of the genus from that which is peculiar to the individual,—
and no proof is correct, unless founded on the former; the intellect
further determines whether certain qualities of a thing are essential
or non-essential. Imagination has none of these functions. It only
perceives the individual, the compound in that aggregate condition
in which it presents itself to the senses; or it combines things which
exist separately, joins some of them together, and represents them
all as one body or as a force of the body. Hence it is that some
imagine a man with a horse’s head, with wings, etc. This is called a
fiction, a phantasm; it is a thing to which nothing in the actual world
corresponds. Nor can imagination in any way obtain a purely
immaterial image of an object, however abstract the form of the
image may be. Imagination yields therefore no test for the reality of
a thing.

Hear what profit we derive from the preliminary disciplines, and how
excellent the propositions are which we learn through them. Know
that there are certain things, which would appear impossible, if
tested by man’s imagination, being as inconceivable as the co-
existence of two opposite properties in one object; yet the existence
of those same things, which cannot be represented by imagination,
is nevertheless established by proof, and attested by their reality.
E.g., Imagine a large globe, of any magnitude you like, even as large
as the all-encompassing sphere; further an axis passing through the
centre, and two persons standing on the two extremities of the axis
in such a manner that their feet are in the same straight line with
the axis, which may be either in the plane of the horizon or not; in
the first case both persons would fall, in the second case one,
namely the one who stands on the lower extremity would fall, the
other would remain standing, as far as our imagination can perceive.
It has however, already been proved that the earth has the form of a
globe, that it is inhabited on both extremities of a certain diameter,
that both the inhabitants have their heads towards the heaven, and
their legs towards each other, and yet neither can possibly fall, nor
can it be imagined; for it is incorrect to say that the one extremity is
above, the other below; but the term “above” and “below” apply to
both of them as regards their relative position to each other.
Similarly it has been proved in the second chapter of the book on
Conic Sections, that two lines, which at first are at a certain distance
from each other, may approach each other in the same proportion as
they are produced further, and yet would never meet, even if they
were produced to infinity, although they are observed to be
constantly converging. This is a fact [131]which cannot easily be
conceived, and which does not come within the scope of
imagination. Of these two lines the one is straight, the other curved,
as stated in the aforementioned book. It has consequently been
proved that things which cannot be perceived or imagined, and
which would be found impossible if tested solely by imagination, are
nevertheless in real existence. The non-existence of things which are
represented by imagination as possible has likewise been established
by proof, e.g., the corporeality of God, and His existence as a force
residing in a body. Imagination perceives nothing except bodies, or
properties inherent in bodies.

It has thus been clearly shown that in man exists a certain faculty
which is entirely distinct from imagination, and by which the
necessary, the possible, and the impossible can be distinguished
from each other. This inquiry is most useful. It is of the greatest
profit to him who desires to guard himself against the errors of men
guided by imagination! Do not think that the Mutakallemim ignore
this altogether; to some extent they do take it into consideration;
they know it, and call that which can be imagined without having
reality—as, e.g., the corporeality of God—a phantom and a fancy;
they state frequently that such phantoms are not real. It is for this
reason that they advance the first nine propositions and establish on
them the proof of the tenth, according to which all those imaginable
things which they wish to admit as possible are really possible,
because of the similarity of all atoms and the equality of all accidents
as regards their accidentality, as we have explained.

Consider, O reader, and bear in mind that this requires deep


research. For there are certain notions which some believe to be
founded on reason, while others regard them as mere fictions. In
such cases it would be necessary to find something that could show
the difference between conceptions of the intellect and mere
imaginary fancies. When the philosopher, in his way of expressing
himself, contends, “Reality is my evidence; by its guidance I examine
whether a thing is necessary, possible, or impossible,” the religionist
replies, “This is exactly the difference between us; that which
actually exists, has, according to my view, been produced by the will
of the Creator, not by necessity; just as it has been created with that
special property, it might have been created with any other property,
unless the impossibility which you postulate be proved by a logical
demonstration.”

About this admissibility (of imaginable things) I shall have to say


more, and I shall return to it in various parts of this treatise; for it is
not a subject which should be rejected in haste and on the spur of
the moment.

Eleventh Proposition.

“The existence of the infinite is in every respect impossible.” The


following is an explanation of this proposition. The impossibility of
the existence of an infinite body has been clearly demonstrated; the
same can be said of an infinite number of bodies, though each of
them be finite, if these beings, infinite in number, exist at the same
time; equally impossible is the existence of an infinite series of
causes, namely, that a certain thing should be the cause of another
thing, but itself the effect of another cause, which again is the result
of another cause, and so on to infinity, or that things in an infinite
series, either bodies or ideals, should be in actual existence, and
[132]in causal relation to each other. This causal relation is the
essential order of nature, in which, as has been fully proved, the
infinite is impossible. As regards the virtual and the accidental
existence of the infinite, it has been established in some cases; it
has been proved, e.g., that a body can virtually be divided ad
infinitum, also that time can be divided ad infinitum; in other cases it
is still an open question, as, e.g., the existence of the infinite in
succession, which is called the accidental infinite, i.e., a series of
things in which one thing comes forth when the other is gone, and
this again in its turn succeeded a thing which had ceased to exist,
and so on ad infinitum. This subject requires deep research.

Those who boast that they have proved the eternity of the Universe
say that time is infinite; an assertion which is not necessarily
erroneous; for only when one atom has ceased to exist, the other
follows. Nor is it absolutely wrong, when they assert, that the
accidents of the substance succeed each other in an infinite series,
for these accidents do not co-exist, but come in succession one after
the other, and the impossibility of the infinite in that case has not
been proved. The Mutakallemim, however, make no difference
between the existence of an infinite body and the divisibility of a
body or of time ad infinitum, between the co-existence of an infinite
number of things, as e.g., the individual human beings who exist at
present, and the infinite number of beings successively existing, as,
e.g., Reuben the son of Jacob, and Jacob the son of Isaac, and Isaac
the son of Abraham, and so on to infinity. This is according to their
opinion as inadmissible as the first case; they believe these four
forms of the infinite to be quite equal. Some of the Mutakallemim
endeavour to establish their proposition concerning the last named
form of the infinite, and to demonstrate its impossibility by a method
which I shall explain in this treatise; others say that this impossibility
is a self-evident axiom and requires no further proof. But if it were
undoubtedly wrong to assume that an infinite number of things can
exist in succession, although that link of the series which exists at
present is finite, the inadmissibility of the eternity of the Universe
would be equally self-evident, and would not require for its proof
any other proposition. This, however, is not the place for
investigating the subject.
Twelfth Proposition.

“The senses are not always to be trusted.” For two reasons the
Mutakallemim find fault with the perception of the senses. First, the
senses are precluded from perceiving many objects, either on
account of the smallness of the objects—this is the case with the
atoms, as we have already stated—or on account of the remoteness
of the objects from the person who desires to perceive them; e.g.,
we cannot see, hear, or smell at a distance of many miles; nor do we
perceive the motion of the heavens. Secondly, the senses
misapprehend the objects of their perception: a large object appears
small from a distance; a small object immersed in water appears
larger; a crooked thing appears straight when partly placed in water,
and partly out of it; things appear yellow to a person suffering from
jaundice; sweet things are bitter to him whose tongue has imbibed
red gall; and they mention many other things of this kind. Therefore
they say, we cannot trust our senses so far as to establish any proof
on their perceptions. You must not believe [133]that the
Mutakallemim had no purpose in agreeing upon this proposition, or
as most of the later adherents of that school affirm, that the first
Mutakallemim had no ulterior object in endeavouring to prove the
existence of atoms. On the contrary, every proposition here
mentioned is indispensable; if one of these be rejected, the whole
theory falls to the ground. The last-mentioned proposition is of
particular importance; for when our senses perceive things by which
any of the foregoing propositions are confuted, the Mutakallemim
say that no notice should be taken of the perception of the senses
so long as the proposition is supported by the testimony of the
intellect, and established (as they believe) by proof. Thus they say
that the continuous motion is interrupted by moments of rest; that
the millstone in its motion is broken into atoms; that the white
colour of a garment ceases to exist, and another whiteness comes in
its stead. All these theories are contrary to what the eye perceives,
and many inferences are drawn from the assumed existence of a
vacuum, all of which are contradicted by the senses. The
Mutakallemim, however, meet these objections by saying, whenever
they can do so, that the perception of these things is withheld from
the senses; in other instances they maintain that the contradiction
has its source in the deceptive character of the senses. You know
that this theory is very ancient, and was the pride of the sophists,
who asserted that they themselves were its authors; this is stated by
Galenus in his treatise on natural forces; and you know well what he
says of those who will not admit the evidence of the senses.

Having discussed these propositions, I now proceed to explain the


theory of the Mutakallemim concerning the above-mentioned four
problems.
[Contents]
CHAPTER LXXIV
In this chapter will be given an outline of the proofs by which the
Mutakallemim attempt to demonstrate that the universe is not
eternal. You must of course not expect that I shall quote their
lengthy arguments verbatim; I only intend to give an abstract of
each proof, to show in what way it helps to establish the theory of
the creatio ex nihilo or to confute the eternity of the universe, and
briefly to notice the propositions they employed in support of their
theory. If you were to read their well-known and voluminous
writings, you would not discover any arguments with which they
support their view left unnoticed in the present outline, but you
might find there greater copiousness of words combined with more
grace and elegance of style; frequently they employ rhyme, rhythm,
and poetical diction, and sometimes mysterious phrases which
perhaps are intended to startle persons listening to their discourses,
and to deter those who might otherwise criticize them. You would
also find many repetitions; questions propounded and, as they
believe, answered, and frequent attacks on those who differ from
their opinions.

The First Argument.

Some of the Mutakallemim thought that by proving the creation of


one thing, they demonstrated the creatio ex nihilo in reference to
the entire universe. E.g., Zaid, who from a small molecule had
gradually been brought [134]to a state of perfection, has undoubtedly
not effected this change and development by his own efforts, but
owes it to an external agency. It is therefore clear that an agent is
required for such organization and successive transmutation. A
palm-tree or any other object might equally be selected to illustrate
this idea. The whole universe, they argue, is analogous to these
instances. Thus you see how they believe that a law discovered in
one thing may equally be applied to everything.

The Second Argument.

This argument is likewise based on the belief that the proof by which
the creation of one thing is demonstrated, holds good for the creatio
ex nihilo in reference to the whole universe. E.g., a certain
individual, called Zaid, who one time was not yet in existence,
subsequently came into existence; and if it be assumed that Amr, his
father, was the cause of his existence, Amr himself must likewise
have passed from non-existence into existence; suppose then that
Zaid’s father unquestionably owed his origin to Khaled, Zaid’s
grandfather, it would be found that Khaled himself did not exist from
eternity, and the series of causes could thus be carried back to
infinity. But such an infinite series of beings is inadmissible according
to the theory of the Mutakallemim, as we have shown in our
discussion of the eleventh proposition. In continuing this species of
reasoning, you come to a first man, who had no parent, viz. Adam.
Then you will of course ask, whence came this first man? If, e.g., the
reply be given that he was made out of earth, you will again inquire,
“Whence came that earth?” “Out of water.” “Whence came the
water?” The inquiry would be carried on, either ad infinitum, which
is absurd, or until you meet with a something that came into
existence from absolute non-existence; in this latter case you would
arrive at the real truth; here the series of inquiries ends. This result
of the question proves, according to the opinion of the
Mutakallemim, that the whole universe came into existence from
absolute non-existence.

The Third Argument.


The atoms of things are necessarily either joined together or
separate, and even the same atoms may at one time be united at
another disunited. It is therefore evident that the nature of the
atoms does not necessitate either their combination or their
separation; for if they were separate by virtue of their nature they
would never join, and if they were joined by virtue of their nature,
they could never again be separated. Thus there is no reason why
atoms should rather be combined than separate, or vice versâ, why
rather in a state of separation than of combination. Seeing that
some atoms are joined, others separate, and again others subject to
change, they being combined at one time and separated at another,
the fact may therefore be taken as a proof that the atoms cannot
combine or separate without an agent. This argument, according to
the opinion of the Mutakallemim, establishes the theory that the
universe has been created from nothing. You have already been told,
that those who employ this argument rely on the first proposition of
the Mutakallemim with its corollaries. [135]

The Fourth Argument.

The whole Universe is composed of substance and accidents; every


substance must possess one accident or more, and since the
accidents are not eternal, the substance, the substratum of the
accidents, cannot be eternal; for that which is joined to transient
things and cannot exist without them is itself transient. Therefore
the whole Universe has had a beginning. To the objection, that the
substance may possibly be eternal while the accidents, though in
themselves transient, succeed each other in an infinite series, they
reply that, in this case, an infinite number of transient things would
be in existence, an eventuality which, according to their theory, is
impossible. This argument is considered by them the best and
safest, and has been accepted by many of them as a strict proof. Its
acceptance implies the admission of the following three propositions,
the object of which is well understood by philosophers. (1) An
infinite series of things, of which the one succeeds when the other
has ceased to exist, is impossible. (2) All accidents have a beginning.
—Our opponent, who defends the theory of the eternity of the
universe, can refute this proposition by pointing to one particular
accident, namely to the circular motion of the sphere; for it is held
by Aristotle that this circular motion is eternal, and, therefore, the
spheres which perform this motion are, according to his opinion,
likewise eternal. It is of no use to prove that all other accidents have
a beginning; for our opponent does not deny this; he says that
accidents may supervene an object which has existed from eternity,
and may follow each other in rotation. He contents himself with
maintaining that this particular accident, viz., circular motion, the
motion of the heavenly sphere, is eternal, and does not belong to
the class of transient accidents. It is therefore necessary to examine
this accident by itself, and to prove that it is not eternal. (3) The
next proposition which the author of this argument accepts is as
follows: Every material object consists of substance and accidents,
that is to say, of atoms and accidents in the sense in which the
Mutakallemim use the term. But if a material object were held to be
a combination of matter and form, as has been proved by our
opponent, it would be necessary to demonstrate that the primal
matter and the primal form are transient, and only then the proof of
the creatio ex nihilo would be complete.

The Fifth Argument.

This argument is based on the theory of Determination, and is made


much of by the Mutakallemim. It is the same as the theory which I
explained in discussing the tenth proposition. Namely, when they
treat either of the Universe in general, or of any of its parts, they
assume that it can have such properties and such dimensions as it
actually has; that it may receive such accidents as in reality are
noticed in it, and that it may exist in such a place and at such a time
as in fact is the case; but it may be larger or smaller, may receive
other properties and accidents, and come to existence at an earlier
or a later period, or in a different place. Consequently, the fact that a
thing has been determined in its composition, size, place, accident
and time—a variation in all these points being possible—is a proof
that a being exists which freely chooses and determines these divers
relations; and the circumstance [136]that the Universe or a part of it
requires a being able to make this selection, proves that the
Universe has been created ex nihilo. For there is no difference which
of the following expressions is used: to determine, to make, to
create, to produce, to originate, or to intend; these verbs have all
one and the same meaning. The Mutakallemim give a great many
examples, both of a general and a special character. They say it is
not more natural for earth to be under water than to be above
water; who then determined its actual position? Or, is it more natural
that the sun is round than that it should be square or triangular; for
all qualities have the same relation to a body capable of possessing
them. Who then determined one particular quality? In a similar way
they treat of every individual being; when, e.g., they notice flowers
of different colours, they are unable to explain the phenomenon, and
they take it as a strong proof in favour of their theory; they say,
“Behold, the earth is everywhere alike, the water is alike; why then
is this flower red and that one yellow?” Some being must have
determined the colour of each, and that being is God. A being must
therefore exist which determines everything, both as regards the
Universe generally, and each of its parts individually. All this is the
logical consequence of the tenth proposition. The theory of
determination is moreover adopted by some of those who assume
the eternity of the Universe, as will be explained below. In
conclusion, I consider this to be the best argument; and in another
part I shall more fully acquaint you with the opinion I have formed
concerning the theory of Determination.
The Sixth Argument.

One of the modern Mutakallemim thought that he had found a very


good argument, much better than any advanced hitherto, namely,
the argument based on the triumph of existence over non-existence.
He says that, according to the common belief, the existence of the
Universe is merely possible; for if it were necessary, the Universe
would be God—but he seems to forget that we are at issue with
those who, whilst they believe in the existence of God, admit at the
same time the eternity of the Universe.—The expression “A thing is
possible” denotes that the thing may either be in existence or not in
existence, and that there is not more reason why it should exist than
why it should not exist. The fact that a thing, the existence of which
is possible, actually does exist—although it bears the same relation
to the state of existence as to that of non-existence—proves that
there is a Being which gave the preference to existence over non-
existence. This argument is very forcible; it is a modified form of the
foregoing argument which is based on the theory of determination.
He only chose the term “preference” instead of “determination,” and
instead of applying it to the properties of the existing being he
applies it to “the existence of the being itself.” He either had the
intention to mislead, or he misunderstood the proposition, that the
existence of the Universe is possible. Our opponent who assumes
the eternity of the Universe, employs the term “possible,” and says,
“the existence of the Universe is possible” in a sense different from
that in which the Mutakallem applies it, as will be explained below.
Moreover it may be doubted whether the conclusion, that the
Universe owes its origin to a being which is able to give preference
to existence over non-existence, is correct. For [137]we may apply
the terms “preference” and “determination” to anything capable of
receiving either of two properties which are contrary or opposed to
each other; and when we find that the thing actually possesses one
property and not the other, we are convinced that there exists a
determining agent. E.g., you say that a piece of copper could just as
well be formed into a kettle as into a lamp; when we find that it is a
lamp or a kettle, we have no doubt that a deciding and determining
agent had advisedly chosen one of the two possible forms; for it is
clear that the substance of copper existed, and that before the
determination took place it had neither of the two possible forms
which have just been mentioned. When, however, it is the question
whether a certain existing object is eternal, or whether it has passed
from non-existence into existence, this argument is inadmissible; for
it cannot be asked who decided in favour of the existence of a thing,
and rejected its non-existence, except when it has been admitted
that it has passed from non-existence into existence; in the present
case this is just the point under discussion. If we were to take the
existence and the non-existence of a thing as mere objects of
imagination, we should have to apply the tenth proposition which
gives prominence to imagination and fiction, and ignores the things
which exist in reality, or are conceived by the intellect. Our
opponent, however, who believes in the eternity of the Universe, will
show that we can imagine the non-existence of the universe as well
as we can imagine any other impossibility. It is not my intention to
refute their doctrine of the creatio ex nihilo: I only wish to show the
incorrectness of their belief that this argument differs from the one
which precedes; since in fact the two arguments are identical, and
are founded on the well-known principle of determination.

The Seventh Argument.

One of the modern Mutakallemim says that he is able to prove the


creation of the Universe from the theory put forth by the
philosophers concerning the immortality of the soul. He argues thus:
If the world were eternal the number of the dead would necessarily
be infinite, and consequently an infinite number of souls would
coexist, but it has long since been shown that the coexistence of an
infinite number of things is positively impossible. This is indeed a
strange argument! One difficulty is explained by another which is still
greater! Here the saying, well known among the Arameans, may be
applied: “Your guarantee wants himself a guarantee.” He rests his
argument on the immortality of the soul, as though he understood
this immortality, in what respect the soul is immortal, or what the
thing is which is immortal! If, however, he only meant to controvert
the opinion of his opponent, who believed in the eternity of the
Universe, and also in the immortality of the soul, he accomplished
his task, provided the opponent admitted the correctness of the idea
which that Mutakallem formed of the philosopher’s view on the
immortality of the soul. Some of the later philosophers explained this
difficulty as follows: the immortal souls are not substances which
occupy a locality or a space, and their existence in an infinite
number is therefore not impossible. You must bear in mind that
those abstract beings which are neither bodies nor forces dwelling in
bodies, and which in fact are ideals—are altogether incapable of
being represented as a [138]plurality unless some ideals be the cause
of the existence of others, and can be distinguished from each other
by the specific difference that some are the efficient cause and
others the effect; but that which remains of Zaid [after his death] is
neither the cause nor the effect of that which is left of Amr, and
therefore the souls of all the departed form only one being as has
been explained by Ibn Bekr Ibn Al-zaig, and others who ventured to
speak on these profound subjects. In short, such intricate
disciplines, which our mind can scarcely comprehend, cannot furnish
any principles for the explanation of other subjects.—It should be
noted that whoever endeavours to prove or to disprove the eternity
of the Universe by these arguments of the Mutakallemim, must
necessarily rely on one of the two following propositions, or on both
of them; namely on the tenth proposition, according to which the
actual form of a thing is merely one of many equally possible forms,
and which implies that there must be a being capable of making the
special selection; or on the eleventh proposition which rejects the
existence of an infinite series of things coming successively into
existence. The last-named proposition is demonstrated in various
ways, e.g., they advert to a class of transient individuals, and to a
certain particular date. From the theory which asserts the eternity of
the Universe, it would follow that the individuals of that class up to
that particular date are infinite in number; a thousand years later the
individuals of that class are likewise infinite in number; the last
number must exceed the previous one by the number of the
individuals born in those thousand years, and consequently one
infinite number would be larger than another. The same argument is
applied to the revolutions of the heavenly sphere, and in like manner
it is shown that one infinite number of revolutions would be larger
than another; the same result is obtained when revolutions of one
sphere are compared with those of another moving more slowly; the
revolutions of both spheres [though unequal] would be infinite in
number. Similarly they proceed with all those accidents which are
subject to destruction and production; the individual accidents that
have passed into non-existence are counted and represented as
though they were still in existence, and as though they were things
with a definite beginning; this imaginary number is then either
increased or reduced. Yet all these things have no reality and are
mere fictions. Abunazar Alfarabi in criticizing this proposition, has
exposed all its weak points, as you will clearly perceive, when you
study his book on the changeable beings earnestly and
dispassionately. These are the principal arguments of the
Mutakallemim in seeking to establish the creatio ex nihilo. Having
thus proved that the Universe is not eternal, they necessarily infer
that there is an Agens who created it in accordance with His
intention, desire and will. They then proceed to prove the unity of
that Agens as I am going to point out in the next chapter.

You might also like