Skip to content

Commit

Permalink
Standardise auth variables (#93)
Browse files Browse the repository at this point in the history
* docs: use "username" in where username would be used in code examples

* docs: fix typos

* docs: remove part about creating a .env file
  • Loading branch information
mjfwebb authored Jan 8, 2024
1 parent 6eab853 commit 189a3c3
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphql = new Neo4jGraphQL({
typeDefs,
driver,
});
const schema = await neo4jgraphql.getSchema();
const schema = await neo4jGraphql.getSchema();
const server = new ApolloServer<Neo4jGraphQLContext>({
schema,
Expand Down Expand Up @@ -76,15 +76,15 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphql = new Neo4jGraphQL({
typeDefs,
driver,
});
const schema = await neo4jgraphql.getSchema();
const schema = await neo4jGraphql.getSchema();
const server = new ApolloServer({
schema,
Expand Down Expand Up @@ -130,15 +130,15 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphql = new Neo4jGraphQL({
typeDefs,
driver,
});
const schema = await neo4jgraphql.getSchema();
const schema = await neo4jGraphql.getSchema();
const server = new ApolloServer<Neo4jGraphQLContext>({
schema,
Expand Down Expand Up @@ -174,15 +174,15 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphql = new Neo4jGraphQL({
typeDefs,
driver,
});
const schema = await neo4jgraphql.getSchema();
const schema = await neo4jGraphql.getSchema();
const server = new ApolloServer({
schema,
Expand All @@ -201,5 +201,3 @@ console.log(`🚀 Server ready at: ${url}`);
----
=====
====


16 changes: 8 additions & 8 deletions modules/ROOT/pages/driver-configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down Expand Up @@ -61,7 +61,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down Expand Up @@ -93,7 +93,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const session = driver.session();
Expand Down Expand Up @@ -126,7 +126,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const session = driver.transaction();
const transaction = session.beginTransaction();
Expand Down Expand Up @@ -158,7 +158,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const ogm = new OGM({ typeDefs, driver });
Expand All @@ -185,7 +185,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand All @@ -207,7 +207,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const ogm = new OGM({ typeDefs, driver });
Expand Down Expand Up @@ -235,7 +235,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down
16 changes: 3 additions & 13 deletions modules/ROOT/pages/getting-started/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,6 @@ To create an instance of the Neo4j GraphQL Library, you need a Neo4j driver to c
+
image::neo4j-aura-dashboard.png[width=500]

. Create a new file `.env` with the credentials described in the previous step.
It should look like this:
+
[source, config]
----
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
NEO4J_URI=neo4j+s://0083654f.databases.neo4j.io
----

=== Using a Neo4j database

For a database located at the default "bolt://localhost:7687" (see more about https://neo4j.com/docs/operations-manual/current/configuration/ports[port configuration]), with the username "neo4j" and the password "password", add the following to the bottom of your `index.js` file:
Expand All @@ -125,7 +115,7 @@ For a database located at the default "bolt://localhost:7687" (see more about ht
----
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down Expand Up @@ -191,7 +181,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down Expand Up @@ -302,4 +292,4 @@ This concludes the tutorial.
By now, you should have a GraphQL API connected to a Neo4j database, to which you added two nodes.

To learn more, keep reading the documentation about xref:queries-aggregations/index.adoc[Queries and aggregations] or alternatively learn how to use the xref:getting-started/toolbox.adoc[Neo4j GraphQL Toolbox].
For more advanced database settings, refer to the xref:driver-configuration.adoc[Driver configuration] page.
For more advanced database settings, refer to the xref:driver-configuration.adoc[Driver configuration] page.
26 changes: 7 additions & 19 deletions modules/ROOT/pages/integrations/apollo-federation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ const typeDefs = `#graphql
}
`;
const {
NEO4J_URI = "neo4j://localhost:7687/neo4j",
NEO4J_USERNAME = "neo4j",
NEO4J_PASSWORD = "password",
} = process.env;
const driver = neo4j.driver(NEO4J_URI, neo4j.auth.basic("username", "password"));
const driver = neo4j.driver(NEO4J_URI, neo4j.auth.basic(NEO4J_USERNAME, NEO4J_PASSWORD));
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphQL = new Neo4jGraphQL({
typeDefs,
driver,
})
Expand All @@ -46,7 +40,7 @@ console.log(`🚀 Server ready at ${url}`);

== Setup

To proceed with the convertion, follow these steps:
To proceed with the conversion, follow these steps:

. Create a directory for a new project and `cd` into it:
+
Expand Down Expand Up @@ -224,7 +218,7 @@ For that, the following line needs to be changed:

[source, javascript]
----
const schema = neo4jgraphql.getSubgraphSchema();
const schema = neo4jGraphql.getSubgraphSchema();
----

== Conclusion
Expand All @@ -244,15 +238,9 @@ const typeDefs = `#graphql
}
`;
const {
NEO4J_URI = "neo4j://localhost:7687/neo4j",
NEO4J_USERNAME = "neo4j",
NEO4J_PASSWORD = "password",
} = process.env;
const driver = neo4j.driver(NEO4J_URI, neo4j.auth.basic(NEO4J_USERNAME, NEO4J_PASSWORD));
const driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("username", "password"));
const neo4jgraphql = new Neo4jGraphQL({
const neo4jGraphQL = new Neo4jGraphQL({
typeDefs,
driver,
})
Expand All @@ -271,4 +259,4 @@ For further iteration, this subgraph can also be composed into a supergraph.
Check Apollo's guides for more instructions:

* https://www.apollographql.com/docs/federation/quickstart/studio-composition[Composition in Apollo Studio]
* https://www.apollographql.com/docs/federation/quickstart/local-composition[Local composition]
* https://www.apollographql.com/docs/federation/quickstart/local-composition[Local composition]
2 changes: 1 addition & 1 deletion modules/ROOT/pages/integrations/relay-compatibility.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ However, configuration is required for it to provide a mechanism for refetching

== Object identification

In order for a Relay client to be able to refetch objects, each type must have a unique object indentifier which can be used for this purpose.
In order for a Relay client to be able to refetch objects, each type must have a unique object identifier which can be used for this purpose.
A server then informs a Relay client that this requirement has been satisfied by having types that implement the `Node` directive, which has the following definition:

[source, graphql]
Expand Down
4 changes: 2 additions & 2 deletions modules/ROOT/pages/introspector.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import neo4j from "neo4j-driver";
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const sessionFactory = () => driver.session({ defaultAccessMode: neo4j.session.READ })
Expand Down Expand Up @@ -70,7 +70,7 @@ import neo4j from "neo4j-driver";
const driver = neo4j.driver(
"neo4j://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const sessionFactory = () =>
Expand Down
12 changes: 6 additions & 6 deletions modules/ROOT/pages/migration/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const typeDefs = `
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({
Expand All @@ -71,7 +71,7 @@ const typeDefs = `
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({
Expand Down Expand Up @@ -107,7 +107,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({
Expand Down Expand Up @@ -144,7 +144,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
Expand Down Expand Up @@ -176,7 +176,7 @@ neoSchema = new Neo4jGraphQL({
typeDefs,
config: {
enableRegex: true
}
}
});
----
a|
Expand Down Expand Up @@ -839,7 +839,7 @@ Note that defining `labels` means taking control of the database labels of the n
Indexes and constraints in Neo4j only support a single label, for which the first element of the `labels` argument will be used. +
{nbsp} +
As before, providing none of these arguments results in the node label being the same as the GraphQL type name.
This can cause implications on constraits.
This can cause implications on constraints.
For instance, in the case where unique constraint is asserted for the label `Tech` and the property `name`: +
{nbsp} +
[source, graphql, indent=0]
Expand Down
6 changes: 3 additions & 3 deletions modules/ROOT/pages/migration/ogm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const ogm = new OGM({ typeDefs, driver, driverConfig: { database: "some-other-database" } });
Expand All @@ -43,8 +43,8 @@ const typeDefs = `#graphql
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const ogm = new OGM({ typeDefs, driver, database: "some-other-database" });
----
----
2 changes: 1 addition & 1 deletion modules/ROOT/pages/ogm/directives.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import neo4j from "neo4j-driver";
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("admin", "password")
neo4j.auth.basic("username", "password")
);
const typeDefs = `
Expand Down
4 changes: 2 additions & 2 deletions modules/ROOT/pages/ogm/installation.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import { createJWT, comparePassword } from "./utils"; // example util function,
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const typeDefs = `#graphql
Expand Down Expand Up @@ -237,7 +237,7 @@ const neo4j = require("neo4j-driver");
const driver = neo4j.driver(
"bolt://localhost:7687",
neo4j.auth.basic("neo4j", "password")
neo4j.auth.basic("username", "password")
);
const typeDefs = `
Expand Down
Loading

0 comments on commit 189a3c3

Please sign in to comment.