Giter VIP home page Giter VIP logo

Comments (3)

johnymontana avatar johnymontana commented on July 25, 2024

@chaymag could you try again now with the updated version? I've updated the version of neo4j-graphql.js used which should include support for custom scalars.

Also, we're working on adding proper DateTime support to neo4j-graphql.js soon, so once this is merged in a custom scalar won't be needed and will work out of the box with the Neo4j temporal types.

from grand-stack-starter.

JohnathanMaravilla avatar JohnathanMaravilla commented on July 25, 2024

@johnymontana,

I've updated neo4j-graphql-js to ^1.0.5 and I'm still having the same issue @chaymag originally reported while attempting to use the DateTime custom scalar within the okgrow/graphql-scalars package , as well as the issues I've outlined in issue #15.

from grand-stack-starter.

mikejoconnor avatar mikejoconnor commented on July 25, 2024

This is due to the starter using makeAugmenentedSchema() where the install instructions for DateTime are using makeExecutableSchema.

After spending more time on this than I care to admit, I have it working. Here is my index.js

import { ApolloServer, makeExecutableSchema } from "apollo-server";
import { v1 as neo4j } from "neo4j-driver";
import { makeAugmentedSchema, augmentTypeDefs } from "neo4j-graphql-js";
import dotenv from "dotenv";

import { DateTime, DateTimeScalar} from "@okgrow/graphql-scalars"

// set environment variables from ../.env
dotenv.config();

/*
 * Create an executable GraphQL schema object from GraphQL type definitions
 * including autogenerated queries and mutations.
 * Optionally a config object can be included to specify which types to include
 * in generated queries and/or mutations. Read more in the docs:
 * https://grandstack.io/docs/neo4j-graphql-js-api.html#makeaugmentedschemaoptions-graphqlschema
 */


const schema = makeExecutableSchema({
  typeDefs: [
    DateTimeScalar, augmentTypeDefs(typeDefs)
  ],
  resolverValidationOptions: {
    requireResolversForResolveType: false
  },
  resolvers: {
    DateTime,
  },
});

const augmentedSchema = makeAugmentedSchema({
  schema: schema,
  //typeDefs: typeDefs

});

/*
 * Create a Neo4j driver instance to connect to the database
 * using credentials specified as environment variables
 * with fallback to defaults
 */
const driver = neo4j.driver(
  process.env.NEO4J_URI || "bolt://localhost:7687",
  neo4j.auth.basic(
    process.env.NEO4J_USER || "neo4j",
    process.env.NEO4J_PASSWORD || "neo4j"
  )
);

/*
 * Create a new ApolloServer instance, serving the GraphQL schema
 * created using makeAugmentedSchema above and injecting the Neo4j driver
 * instance into the context object so it is available in the
 * generated resolvers to connect to the database.
 */
const server = new ApolloServer({
  context: { driver },
  schema: augmentedSchema
});

server.listen(process.env.GRAPHQL_LISTEN_PORT, "0.0.0.0").then(({ url }) => {
  console.log(`GraphQL API ready at ${url}`);
});

from grand-stack-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.