Fullstack GraphQL The Complete Guide To Writing GraphQL Servers and Clients With TypeScript Gaetano Checinskil 2024 Scribd Download
Fullstack GraphQL The Complete Guide To Writing GraphQL Servers and Clients With TypeScript Gaetano Checinskil 2024 Scribd Download
com
https://textbookfull.com/product/fullstack-
graphql-the-complete-guide-to-writing-graphql-
servers-and-clients-with-typescript-gaetano-
checinskil/
https://textbookfull.com/product/beginning-graphql-with-react-nodejs-
and-apollo-greg-lim/
textbookfull.com
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
https://textbookfull.com/product/introduction-to-mineralogy-and-
petrology-2nd-edition-swapan-kumar-haldar/
textbookfull.com
https://textbookfull.com/product/evidence-based-practice-for-nursing-
and-healthcare-quality-improvement-1st-edition-geri-lobiondo-wood/
textbookfull.com
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
© 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
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
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Visualizing Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Pagination with cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Tracking our cursorState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Batching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Cost computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
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.
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.
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:
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.
$ node -v
v10.19.0
Windows
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⁴:
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
In case of problems with installation follow the troubleshooting guide for Linux⁷.
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⁸
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.
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
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.
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
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).
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."
}
}
}
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
}
}
{
"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
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.
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.
Sixth Proposition.
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.
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.
Tenth Proposition.
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.
Eleventh Proposition.
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.
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.