Professional Documents
Culture Documents
Textbook Visual Design of Graphql Data A Practical Introduction With Legacy Data and Neo4J 1St Edition Thomas Frisendal Ebook All Chapter PDF
Textbook Visual Design of Graphql Data A Practical Introduction With Legacy Data and Neo4J 1St Edition Thomas Frisendal Ebook All Chapter PDF
https://textbookfull.com/product/graph-data-science-with-
neo4j-learn-how-to-use-neo4j-5-with-graph-data-science-
library-2-0-and-its-python-driver-for-your-project-scifo/
https://textbookfull.com/product/learning-neo4j-3-x-effective-
data-modeling-performance-tuning-and-data-visualization-
techniques-in-neo4j-jerome-baton/
https://textbookfull.com/product/graph-algorithms-for-data-
science-with-examples-in-neo4j-1st-edition-tomaz-bratanic/
https://textbookfull.com/product/the-visual-imperative-creating-
a-visual-culture-of-data-discovery-1st-edition-ryan/
Introduction to Data Science Data Analysis and
Prediction Algorithms with R 1st Edition By Rafael A.
Irizarry
https://textbookfull.com/product/introduction-to-data-science-
data-analysis-and-prediction-algorithms-with-r-1st-edition-by-
rafael-a-irizarry/
https://textbookfull.com/product/making-data-visual-a-practical-
guide-to-using-visualization-for-insight-1st-edition-danyel-
fisher/
https://textbookfull.com/product/design-of-video-quality-metrics-
with-multi-way-data-analysis-a-data-driven-approach-1st-edition-
christian-keimel-auth/
https://textbookfull.com/product/practical-python-data-
visualization-a-fast-track-approach-to-learning-data-
visualization-with-python-ashwin-pajankar/
https://textbookfull.com/product/practical-data-science-with-sap-
machine-learning-techniques-for-enterprise-data-1st-edition-greg-
foss/
Visual
Design of
GraphQL Data
A Practical Introduction with
Legacy Data and Neo4j
—
Thomas Frisendal
Visual Design of
GraphQL Data
A Practical Introduction with
Legacy Data and Neo4j
Thomas Frisendal
Visual Design of GraphQL Data: A Practical Introduction with
Legacy Data and Neo4j
Thomas Frisendal
Copenhagen S, Denmark
v
Table of Contents
vi
Table of Contents
Relationship Types����������������������������������������������������������������������������������������������77
One-to-One Relationships�����������������������������������������������������������������������������77
One/Zero to Zero/Many Relationships�����������������������������������������������������������77
Self References���������������������������������������������������������������������������������������������77
Many-to-Many Relationships������������������������������������������������������������������������78
Missing Information��������������������������������������������������������������������������������������������80
Properties on Relationships��������������������������������������������������������������������������������80
vii
Table of Contents
Afterword: Summary������������������������������������������������������������������������107
Index�������������������������������������������������������������������������������������������������109
viii
About the Author
Thomas Frisendal is an experienced database
consultant with more than 30 years on
the IT vendor side and as an independent
consultant. He has worked with databases and
data modeling since the late 70s; since 1995
primarily on data warehouse projects. He has a
strong urge to visualize everything as graphs -
even datamodels! He excels in the art of
turning data into information and knowledge.
His approach to information-driven analysis
and design is “New Nordic” in the sense that it represents the traditional
Nordic values such as superior quality, functionality, reliability and
innovation by new ways of communicating the structure and meaning of
the business context.
He lives in Copenhagen, Denmark. His firm, TF Informatik, was
founded in 1995 and is registered in Denmark (DK66048950). He is on
LinkedIn and Twitter @VizDataModeler1. Thomas is an active writer and
speaker.
His recent book about Graph Data Modeling2 has a lot of background
and in-depth guidance on most of what has been presented in this book. It
proposes property graph modeling as a general modeling paradigm. It has
many examples from many contexts.
1
h ttps://twitter.com/VizDataModeler
2
https://technicspub.com/graph-data-modeling/
ix
About the Author
x
About the Technical Reviewer
Ahmed Mohammed is an experienced full stack Java/Angular Developer.
He is skilled in Java, JavaScript, CI/CD, Spring Boot, GraphQL, GraphQL
Apollo, Linux, Microservices in Cloud, and Angular 2/5. He has an MSc
and BSc of Information Technology focused in Web Technologies.
xi
Acknowledgments
Named relationships is one of the fundamental recommendations of
this book. The importance of this was made originally by Prof. Joseph
D. Novak, who was one of the fathers of Concept Mapping in the
development of the psychology of learning.
GraphQL is designed by Facebook, Copyright © 2015-2016. It is now an
open source project, where the software is available under a BSD 3 license.
Refer to www.graphQL.org1 for more information.
The GraphQL @relation schema directive originated at Graphcool,
refer to www.graph.cool2 for more information.
The chapter about using GraphQL with a new graph database draws
heavily on a blogpost Five Common GraphQL Problems and How Neo4j-
GraphQL Aims To Solve Them3 written by Will Lyon of Neo4j4. I am
quoting from it with the author’s kind permission. Thank you!
1
h ttp://www.graphQL.org
2
http://www.graph.cool
3
https://blog.grandstack.io/five-common-graphql-problems-and-how-
neo4j-graphql-aims-to-solve-them-e9a8999c8d43
4
https://neo4j.com
xiii
Introduction
You know the basics of GraphQL, but you are still uncertain about how to
get business content and API structures right in GraphQL?
GraphQL is indeed an attractive data API for applications (and people).
The GraphQL Schema is pivotal to the success of a GraphQL
API. Most development projects involve many stakeholders. There are the
developers, of course, and there are business experts as well as application
owners, who are to consume the content of the API. This means that the
schema is not only a scope contract, but also the authoritative source
of structure and meaning of the context covered by the API. There
are many other contexts, where complex structures and semantics
must be communicated effecetively between a number of people with
various backgrounds. And the trick invariably turns out to be: Use good
visualizations!
The main proposition of this book is graph visualization: GraphQL
Schema structure and meaning must be visualized, and the book shows
you how. Since the schema is a “data graph” containing related concepts
in a network organized as a directed graph, the increasingly popular
property graph paradigm is very appropriate for visualizing GraphQL
structures and semantics.
The second theme of this book is that of quality. GraphQL APIs can
be used in many constellations possibly including legacy data and/or
externally sourced data. Quality must be ensured in all cases. Both on the
definitional level (business terminology etc.) and on the data content level
(meaningful presentation of the data in business-friendly formats). The
book summarizes the top 10 most important focal areas of such quality
assurance remedies.
xv
Introduction
xvi
CHAPTER 1
Visual Design
of GraphQL Data
hat Is GraphQL and Why Is Design
W
Important?
GraphQL is getting a lot of interest. GraphQL is a Facebook open source
project that has its primary information site at http://graphql.org/.1
My interest is the relationship between GraphQL and design. That
relationship is certainly very real. In graphql.org’s own words:
“Describe what’s possible with a type system. GraphQL APIs
are organized in terms of types and fields, not endpoints.
Access the full capabilities of your data from a single endpoint.
GraphQL uses types to ensure apps only ask for what’s possi-
ble and provide clear and helpful errors. Apps can use types to
avoid writing manual parsing code.”
The gist of GraphQL can be seen in the example in Figure 1-1, from
graphql.org.
1
http://graphql.org/
The context of Figure 1-1 is Star Wars metadata. And what you see to
the right is actually part of a GraphQL Schema. What you see on the left
could well be a query to the API, and the resulting set of data will share
exactly that (data) structure.
The open GraphQL project started in 2012 and belongs in the software
architecture universe talked about as APIs these days. In Facebook’s own
terms: “… GraphQL [is] a query language created by Facebook in 2012 for
describing the capabilities and requirements of data models for client-
server applications” (GraphQL on GitHub2).
2
http://facebook.github.io/graphql/October2016/
2
Chapter 1 Visual Design of GraphQL Data
The graphql.org site does a nice job of explaining, so I will not repeat
all of that here. Graphcool has a nice blog post called “GraphQL Server
Basics: The Schema”,3 which includes a good introduction to structure and
behavior of GraphQL. William Lyon of Neo4j (http://www.neo4j.com/4) has
made an excellent overview of GraphQL, which is available as a “refcard”
from Dzone at GraphQL Refcard5 (login is required).
The best tool for getting structure and meaning right is visualization
of the graphs. The property graph approach is very powerful for database
design across many different data stores. And it is equally well suited for
design of data-level APIs, as you will see in this book.
Also notice that the most developers today only have indented bracket
displays with “prettify” functionality available. Type completion, driven by
the GraphQL Schema, is also available.
High-quality data designs are possible only if you get the structure and
the meaning right, and that is what this book is about.
3
h ttps://blog.graph.cool/graphql-server-basics-the-schema-ac5e2950214e
4
http://www.neo4j.com/
5
https://dzone.com/refcardz/an-overview-of-graphql
6
https://apis.guru/graphql-voyager/
7
http://nathanrandal.com/graphql-visualizer/
8
https://brbb.github.io/graphql-rover/
3
Chapter 1 Visual Design of GraphQL Data
4
Chapter 1 Visual Design of GraphQL Data
5
Chapter 1 Visual Design of GraphQL Data
6
CHAPTER 2
GraphQL Concepts
There are a number of concepts defined in the GraphQL context. The
concept model shown in Figure 2-1 lays out all the important ones.
–– One-to-many (arrow)
You can learn more about this diagramming style in my book entitled
Graph Data Modeling for NoSQL and SQL,2 2016, Technics Publications
(visit https://technicspub.com/graph-data-modeling/).
Some concepts, such as Mutation, Input, Function, and Subscription,
are application/server construction services (updates, inserts, DB
mapping, and push services), which also are part of the schema. However,
since my focus is on the structure and meaning of the exposed model in its
own right, I disregard all of them in the following discussion.
1
h ttp://graphql.org/learn/schema/
2
https://technicspub.com/graph-data-modeling/
8
Chapter 2 GraphQL Concepts
The rest of the concepts are pretty much what their names imply. Here
are some one-liner explanations:
Concept Explanation
GraphQL Defines the structure and the meaning of the exposed data model (as
Schema well as the data-manipulation functions, which we do not look at here).
Enum Basically a list of values, which can be applied to a field.
Query The root query defines the anchor point of the application graph (tree)
and shapes the result sets.
Interface Essentially a “view” of an object (or query); it is frequently used for
“subtyping”.
Union A concatenation of results sub-graphs sharing related content.
For example various types of persons, as in users, actors, etc.
Object A business object (think Movie or Starship in the Star Wars example).
Fragment A subset of a sub-graph. Inline fragments are typically used with
union-constructs.
Field The data-bearing things. Can be scalars or lists (yes, like in repeating
groups).
Directive User-definable extensions to the GraphQL syntax.
3
http://www.graph.cool
9
Chapter 2 GraphQL Concepts
4
h ttps://dev-blog.apollodata.com/reusable-graphql-schema-directives-
131fb3a177d1
5
https://github.com/facebook/graphql/blob/master/spec/GraphQL.md
10
Chapter 2 GraphQL Concepts
11
CHAPTER 3
Getting Started
Which Design Levels?
Classical data modeling failed in a number of ways. We have to do better
than that. What did not work well was conceptual modeling, which has
faded away in favor of what one could call “The Great Pragmatic and
Quick, Unified Data Modeling Practice”.
Today many development organizations have a one-step approach
to modeling, which is performed when necessary in the development
process. Logical and physical models have come together. The driving
force is time to delivery, and what the unified process is trying to answer
are two aspects of developing a good solution:
G
etting an Overview
If you don’t know the scope already, you need to get an overview of a
subject area that you are creating a schema for.
Figure 3-1 shows an overview of some business concepts in a car
dealership.
14
Chapter 3 Getting Started
15
Chapter 3 Getting Started
Such an overview will give you a head start on the API, so spend a few
hours on creating one on a whiteboard, have other business people review
it, and let it guide the rest of your schema-definition activities.
You can also consider building an overview bottom up from the data
sources. Frequently a combination of top down and bottom up gives you
what you need.
Note that the concepts on the lowest level are actually the value chain
of the business—starting with budget morphing into procurement and
then to inventory and sales. (And later to maintenance and to profitability
calculations.)
Obviously, there should be no “islands”—everything should be
connected to something.
You can learn a lot more about concept-level analysis and design in my
book entitled Graph Data Modeling for NoSQL and SQL,1 2016, Technics
Publications (visit https://technicspub.com/graph-data-modeling/).
Notice the high degree of connectedness of even a simple business
operation such as a car dealership. Clearly graph representation is the way
to go, and GraphQL developers can learn a lot from such high-level maps,
which today are called “enterprise knowledge graphs”.
Once you get into looking at field properties, the schema data design
will become clearly visible, because concepts, which carry properties, are
business objects, whereas concepts without properties are probably just
abstractions, which you may wish to get rid of, or describe with properties,
as appropriate.
Note that even though you should try to map the enterprise (on a
high-level concept map), you should not take too many, or too big, steps.
In fact, recent developments in the GraphQL community encourage a
stepwise approach and reuse of existing schema parts together with freshly
developed schema parts. We will return briefly to this (schema stitching
and schema binding) in a later chapter.
1
https://technicspub.com/graph-data-modeling/
16
Another random document with
no related content on Scribd:
the Society for six months and who were in the employment of the
Society at the date of commencing the fund, if they were sixteen
years of age or upwards and not over fifty years of age in the case of
males or forty-five years of age in the case of females, should be
members of the fund. The proposed scale of contributions to the
scheme was 5 per cent. of the wages or salary received, and
contributors were to be eligible at sixty years of age to retire on
pension if they so desired. At the age of sixty-five for males and fifty
for females they would be eligible to receive annuities ranging from
25 per cent. of their salaries, after ten years’ payment of
contributions, to 85 per cent. of their salaries after having paid
contributions for fifty-one years. To assist in launching the scheme it
was proposed that the Society should make an initial contribution of
£10,000. It was also proposed that the superannuation fund should
be managed by a committee of seven, which committee should
consist of the chairman and three directors for the time being of the
U.C.B.S. and three representatives of the employees, who must have
at least three years’ service with the Society.
When the scheme was brought forward again at the September
meeting of the Society one of the amendments sent in was from St
George Society, and called for the rejection of the scheme in its
entirety. The motion to reject the scheme was seconded by a
representative of the employees, who referred to the “autocratic”
methods of the directors in adopting this scheme and bringing it
forward without consulting the workers. The result was that the
scheme was disapproved. The scheme which was brought forward by
the S.C.W.S. for the superannuation of their employees suffered the
same fate.
THE INTERNATIONAL CO-OPERATIVE
CONGRESS.
It was as the result of an invitation which came from the Scottish
National Co-operative Conference, held in Kilmarnock in 1910, that
the International Co-operative Congress held in Hamburg in the
autumn of that year decided to come to Glasgow for the 1913
Congress rather than go to Vienna, the claims of which city were
strongly urged by Dr Beno Karpeles, in opposition to the claims of
Glasgow, as set forth by Mr James Deans.
The year 1913 was a big year for Scottish Co-operators, for not only
had they to entertain the International Congress in the autumn, but
Scotland was also the location of the British Congress in the summer,
and pessimists were not wanting who thought that the Co-operators
of Scotland had undertaken a task which was too heavy for them
when they decided to entertain two so great Congresses as the British
and the International in one year. Events proved that the pessimists
were wrong, however. One of the first duties which fell to the lot of
the committee which was appointed to make preparations for the
International Congress was that of finding a suitable house for it, but
they did not require to look far afield. The U.C.B.S. were the owners
of the best hall in the city for the purpose for which it was required.
In St Mungo Hall there was ample accommodation for the Congress
itself, while in the adjoining halls ample space for dining the
delegates could be provided. The Bakery was just across the street,
and cooking and waiting facilities were all that could be desired. So it
was decided that in St Mungo Hall the Congress should be held.
The U.C.B.S. undertook all the work of catering for the delegates at
luncheon each day. They also undertook the provision of the
luncheon which was given by the reception committee on the
Saturday, and they themselves provided the entertainment for one of
the afternoons of Congress. It was universally acknowledged that the
International Congress of 1913 was the best International Co-
operative Congress held, and to this happy result the U.C.B.S.
contributed no small share. The event was one which will not readily
be forgotten by those privileged to take part. Alas, that the
expressions of fraternity so freely uttered then should have been so
soon made of no avail by the outbreak of war.
THE HOLIDAY CAMP.
It is to Mr John Dewar, for many years president of the
Renfrewshire Co-operative Conference Association, that the idea of a
Co-operative holiday camp owes its origin. For many years Mr Dewar
was an enthusiastic Volunteer, and his experiences under canvas
during the annual training periods of his regiment impressed him
with the value of this form of holiday. Associated with him in his
propaganda for a camping association on Co-operative lines was Mr
James Lucas, at that time president of the Glasgow and Suburbs
Conference Association, and latterly, also, Mr John Paton, of the
Renfrewshire Conference council, who had been converted to the
idea as the result of a visit to Douglas, I.O.M., where he had seen the
huge city under canvas which for a number of years housed
thousands of holiday-making Lancashire lads every summer.
By 1910 these gentlemen had been able to get their organisation so
far advanced that they had selected a site on the Ayrshire Coast for
their first camp, and had made arrangements with the farmer who
rented the land. At the last moment, however, the landowner stepped
in and vetoed the whole proceedings. This put an end to doing
anything further with regard to a camp during that year, but the
search for a suitable site continued and, at length, the little farm of
Roseland, situated on Canada Hill, Rothesay, overlooking the Bay,
was secured. The farm was for sale, but the committee in charge of
the arrangements considered that purchase was too bold an initial
step to take, so they leased the farm for six months; securing an
option to purchase at the end of that period if they wished.
Here, in the summer of 1911, the first Scottish Co-operative
holiday camp was established. It was rather a primitive affair, that
first camp. The cooking was done in the little farmhouse, while the
campers had their meals in a large marquee. The U.C.B.S. directors
took a keen interest in the camp from the very beginning. The
catering was done by them, and the catering staff were housed in the
little farmhouse.
Primitive though the arrangements were, they appealed to the
campers, who were unanimous in their praise of the beautiful
situation, the pure air, the perfect catering, and the small outlay for
which they secured a perfect holiday. Thus encouraged, the
committee which had promoted the camp proceeded to organise a
Co-operative society to work it, and in this Co-operative society the
U.C.B.S. took out twenty-five shares. The farm was purchased for
£600, and in September the Baking Society increased the number of
their shares to 100.
In 1912 the camp was much better organised than in 1911, but it
was still far from being what its promoters desired to see it. They
were hampered for lack of funds, however, as the Co-operative
societies were showing caution and a lack of faith in the enterprise,
and were not providing the capital necessary to work it properly as
readily as had been expected. The only fault which the committee
found with the site lay in the fact that in dry summers the water
supply was inadequate. The summer of 1912 also showed them that it
was desirable that something more impervious to rain than a
marquee was desirable for the gatherings of campers and, in order
that these two defects might be put right, they applied to the U.C.B.S.
for a loan of £1,000 on the security of the property. This loan was
granted them, and so good use did they make of the power which it
gave them that, before the time came for opening the camp in 1913,
they had put down a huge storage tank for water, capable of storing
20,000 gallons; and had erected a dining hall large enough to dine
several hundred persons.
The camp was a very great success in the third year. Its popularity
was so great that the committee found it quite impossible to provide
accommodation for all who wished to avail themselves of its facilities
for holiday making, and this has been the case in each succeeding
year, notwithstanding the influence of the war. At the end of the
third season, however, the committee of the association came to the
conclusion that, if the camp was to be made the success they believed
it was capable of becoming, some rearrangement of its management
would require to be made, so they invited the Baking Society to take
it over as a going concern and work it themselves.
They explained to the directors of the Baking Society that they
were not taking this step because they disbelieved in its success, but
solely on the ground that they considered that dual control was not
good for discipline and did not make for good management.
The directors of the Baking Society promised to consider the
matter, and the result was they brought forward to the quarterly
meeting, held in March 1914, a recommendation that the camp
should be taken over, and this recommendation was accepted by the
delegates. Since then the camp has been managed by the U.C.B.S.
In 1914 accommodation was provided for 250 persons, and it is
extremely probable that greatly increased accommodation would
have been provided before now had it not been for the intervention
of the war which, by providing another and much more strenuous
form of camping for the past and prospective frequenters of Canada
Hill, prevented for the time being such further developments.
Doubtless, however, with the return of Europe to sanity, such
developments will take place; until, before many years are past,
almost the whole of the Society’s seven-acre estate will be covered in
the summer and autumn months with the picturesque pyramids of
white canvas.
THE SOCIETY’S PROGRESS.
In all its branches, with the exception of the tearooms, the
progress of the Society during these four years had been remarkable.
In 1913, however, the London Street tearoom was closed, and as soon
as the lease of the Union Halls expired they also were given up. At
the beginning of the period the output had averaged 3,820 sacks per
week, while at its end the average output was 4,648, an increase of
848 sacks per week in four years. The aggregate sales for the year
which ended in July 1914 were £692,600. Truly, the Society had
travelled far from the days when a small two-oven bakehouse
sufficed for all its output. The membership now consisted of 201
societies; which was also a contrast to the eight small struggling
societies which had banded themselves together in the last days of
December 1868 to form the Federation.
The time had now arrived when the Federation was to be put to a
more severe test than ever before since it had attained to years of
maturity. Like a thunderclap the war storm which had been
gathering over Europe during the month of July burst on an
astonished world which had almost come to believe war on such a
gigantic scale impossible, and many were the doubts expressed, even
by sincere wellwishers of the Co-operative movement, as to how it
would weather the storm. The next chapter will tell how one
federation kept the Co-operative flag flying and added to the laurels
it had gained by its devoted and loyal service to the interests of the
common people.
CHAPTER XVIII.
BAKING UNDER WAR CONDITIONS.