diff --git a/README.md b/README.md index 650051c1..54e28b31 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ queryGql :: GqlQuery Nil' OpQuery Schema query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Schema) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Schema) -- Schema type Schema @@ -129,7 +129,7 @@ const { generateSchema } = require('purescript-graphql-client') generateSchema({ dir: './src/generated', // Where you want the generated code to go modulePath: ['Generated', 'Gql'], // The name of the generated module - url: 'http://localhost:4000/graphql' // Your graphql enppdint + url: 'http://localhost:4892/graphql' // Your graphql enppdint }) ``` @@ -148,7 +148,7 @@ generateSchemas({ modulePath: ['Generated', 'Gql'] }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'MySchema' // The name of the module for this single schema } ]) @@ -187,7 +187,7 @@ import Type.Data.List (Nil') ... client :: Client _ Nil' Query Mutation Void <- createClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , authToken: Nothing , headers: [] } @@ -217,10 +217,10 @@ import Type.Data.List (Nil') client :: Client _ Nil' Query Mutation Subscription <- createSubscriptionClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , authToken: Nothing , headers: [] - , websocketUrl: "ws://localhost:4000/subscriptions" + , websocketUrl: "ws://localhost:4892/subscriptions" } let event = subscription client "get_props" @@ -478,5 +478,3 @@ Although the names and scope of the 2 packages are very similar they are not con - This package uses record syntax to make queries whereas purescript-graphqlclient uses applicative/ado syntax - This package allows use of Apollo if you wish (or other lower level graphQL clients) - This package supports subscriptions, watch queries and client caching - - diff --git a/e2e/1-affjax/server-fn.js b/e2e/1-affjax/server-fn.js index 6e179cd7..2b84c97f 100644 --- a/e2e/1-affjax/server-fn.js +++ b/e2e/1-affjax/server-fn.js @@ -9,8 +9,8 @@ module.exports = (onListening) => { prop: String widgets(id: Int): [Widget!]! } - - type Widget { + + type Widget { id: Int name: String! } @@ -38,5 +38,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/e2e/1-affjax/server.js b/e2e/1-affjax/server.js index b8065c5b..333a4759 100644 --- a/e2e/1-affjax/server.js +++ b/e2e/1-affjax/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/e2e/1-affjax/src/Main.purs b/e2e/1-affjax/src/Main.purs index 9a0d3313..770424b5 100644 --- a/e2e/1-affjax/src/Main.purs +++ b/e2e/1-affjax/src/Main.purs @@ -47,7 +47,7 @@ client , mutation :: Void , subscription :: Void } -client = (Client $ AffjaxNodeClient "http://localhost:4000/graphql" []) +client = (Client $ AffjaxNodeClient "http://localhost:4892/graphql" []) -- Schema type Schema = diff --git a/e2e/2-comments/generate-purs-schema.mjs b/e2e/2-comments/generate-purs-schema.mjs index efbaf2d8..c1303d21 100644 --- a/e2e/2-comments/generate-purs-schema.mjs +++ b/e2e/2-comments/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: true }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/e2e/2-comments/server-fn.js b/e2e/2-comments/server-fn.js index 1c956678..f9c7bfcf 100644 --- a/e2e/2-comments/server-fn.js +++ b/e2e/2-comments/server-fn.js @@ -46,5 +46,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/e2e/2-comments/server.js b/e2e/2-comments/server.js index b8065c5b..333a4759 100644 --- a/e2e/2-comments/server.js +++ b/e2e/2-comments/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/e2e/2-comments/src/Main.purs b/e2e/2-comments/src/Main.purs index 667d9442..17511e86 100644 --- a/e2e/2-comments/src/Main.purs +++ b/e2e/2-comments/src/Main.purs @@ -34,4 +34,4 @@ queryGql :: GqlQuery Nil' OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/1-simple/server-fn.js b/examples/1-simple/server-fn.js index 6e179cd7..2b84c97f 100644 --- a/examples/1-simple/server-fn.js +++ b/examples/1-simple/server-fn.js @@ -9,8 +9,8 @@ module.exports = (onListening) => { prop: String widgets(id: Int): [Widget!]! } - - type Widget { + + type Widget { id: Int name: String! } @@ -38,5 +38,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/1-simple/server.js b/examples/1-simple/server.js index b8065c5b..333a4759 100644 --- a/examples/1-simple/server.js +++ b/examples/1-simple/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/1-simple/src/Main.purs b/examples/1-simple/src/Main.purs index e9eae2c9..dc59219e 100644 --- a/examples/1-simple/src/Main.purs +++ b/examples/1-simple/src/Main.purs @@ -27,7 +27,7 @@ queryGql :: GqlQuery Nil' OpQuery Schema query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Schema) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Schema) -- Schema type Schema diff --git a/examples/10-aliases/server-fn.js b/examples/10-aliases/server-fn.js index 6e179cd7..2b84c97f 100644 --- a/examples/10-aliases/server-fn.js +++ b/examples/10-aliases/server-fn.js @@ -9,8 +9,8 @@ module.exports = (onListening) => { prop: String widgets(id: Int): [Widget!]! } - - type Widget { + + type Widget { id: Int name: String! } @@ -38,5 +38,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/10-aliases/server.js b/examples/10-aliases/server.js index b8065c5b..333a4759 100644 --- a/examples/10-aliases/server.js +++ b/examples/10-aliases/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/10-aliases/src/Main.purs b/examples/10-aliases/src/Main.purs index efbef040..5b6f35a8 100644 --- a/examples/10-aliases/src/Main.purs +++ b/examples/10-aliases/src/Main.purs @@ -39,7 +39,7 @@ queryGql :: GqlQuery Nil' OpQuery Schema query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Schema) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Schema) -- Schema type Schema diff --git a/examples/11-unions/generate-purs-schema.mjs b/examples/11-unions/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/11-unions/generate-purs-schema.mjs +++ b/examples/11-unions/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/11-unions/server-fn.js b/examples/11-unions/server-fn.js index 08098477..4ef8d410 100644 --- a/examples/11-unions/server-fn.js +++ b/examples/11-unions/server-fn.js @@ -32,7 +32,7 @@ module.exports = (onListening) => { height: 1.8, id: 1, }; - }else { + }else { return { __typename: "Droid", name: "R2D2", @@ -54,5 +54,5 @@ module.exports = (onListening) => { }) ); - app.listen(4000, onListening); + app.listen(4892, onListening); }; diff --git a/examples/11-unions/server.js b/examples/11-unions/server.js index 8b2fcfbd..4cc61b8c 100644 --- a/examples/11-unions/server.js +++ b/examples/11-unions/server.js @@ -1,3 +1,3 @@ require('./server-fn')(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/11-unions/spago.dhall b/examples/11-unions/spago.dhall index 606c488d..36376273 100644 --- a/examples/11-unions/spago.dhall +++ b/examples/11-unions/spago.dhall @@ -5,5 +5,5 @@ You can edit this file as you like. { name = "my-project" , dependencies = ../../test-deps.dhall , packages = ./packages.dhall -, sources = [ "src/**/*.purs", "test/**/*.purs", "../../src/**/*.purs" ] +, sources = [ "src/**/*.purs", "../../src/**/*.purs" ] } diff --git a/examples/11-unions/src/Main.purs b/examples/11-unions/src/Main.purs index 461a66fe..406a5e2d 100644 --- a/examples/11-unions/src/Main.purs +++ b/examples/11-unions/src/Main.purs @@ -9,8 +9,8 @@ import Effect.Aff (Aff, launchAff_) import Effect.Class.Console (logShow) import Generated.Gql.Schema.Admin (Query) import GraphQL.Client.Args ((=>>)) -import GraphQL.Client.Query (query_) import GraphQL.Client.Operation (OpQuery) +import GraphQL.Client.Query (query_) import GraphQL.Client.Types (class GqlQuery) import GraphQL.Client.Union (GqlUnion(..)) import Type.Data.List (Nil') @@ -39,4 +39,4 @@ queryGql => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/12-directives/generate-purs-schema.mjs b/examples/12-directives/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/12-directives/generate-purs-schema.mjs +++ b/examples/12-directives/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/12-directives/server-fn.js b/examples/12-directives/server-fn.js index af7b2c5e..2acce960 100644 --- a/examples/12-directives/server-fn.js +++ b/examples/12-directives/server-fn.js @@ -9,7 +9,7 @@ module.exports = (onListening) => { directive @cached( """measured in seconds""" ttl: Int = 60 - + """refresh the cache entry""" refresh: Boolean = false ) on QUERY @@ -18,8 +18,8 @@ module.exports = (onListening) => { prop: String widgets(id: Int): [Widget!]! } - - type Widget { + + type Widget { id: Int name: String! } @@ -47,5 +47,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/12-directives/server.js b/examples/12-directives/server.js index 8b2fcfbd..4cc61b8c 100644 --- a/examples/12-directives/server.js +++ b/examples/12-directives/server.js @@ -1,3 +1,3 @@ require('./server-fn')(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/12-directives/src/Main.purs b/examples/12-directives/src/Main.purs index 85e4b9c8..edbb772d 100644 --- a/examples/12-directives/src/Main.purs +++ b/examples/12-directives/src/Main.purs @@ -29,4 +29,4 @@ queryGql :: GqlQuery Directives OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/13-error-boundaries/server-fn.js b/examples/13-error-boundaries/server-fn.js index 32a42cdc..10b4a6a7 100644 --- a/examples/13-error-boundaries/server-fn.js +++ b/examples/13-error-boundaries/server-fn.js @@ -8,8 +8,8 @@ module.exports = (onListening) => { prop: String widgets(id: Int): [Widget!]! } - - type Widget { + + type Widget { id: Int name: String! contains_bad_type: BadType @@ -51,5 +51,5 @@ module.exports = (onListening) => { }) ); - app.listen(4000, onListening); + app.listen(4892, onListening); }; diff --git a/examples/13-error-boundaries/server.js b/examples/13-error-boundaries/server.js index b8065c5b..333a4759 100644 --- a/examples/13-error-boundaries/server.js +++ b/examples/13-error-boundaries/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/13-error-boundaries/src/Main.purs b/examples/13-error-boundaries/src/Main.purs index 0b311ff1..ae564ab6 100644 --- a/examples/13-error-boundaries/src/Main.purs +++ b/examples/13-error-boundaries/src/Main.purs @@ -57,7 +57,7 @@ queryGql name_ q = do client <- liftEffect $ createClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , headers: [] } queryFullRes decodeJson identity (client :: Client UrqlClient { directives :: Proxy Nil', query :: Schema | _ }) name_ q diff --git a/examples/2-codegen/generate-purs-schema.js b/examples/2-codegen/generate-purs-schema.js index bcfeb87f..3f53fdd6 100644 --- a/examples/2-codegen/generate-purs-schema.js +++ b/examples/2-codegen/generate-purs-schema.js @@ -7,5 +7,5 @@ export default () => dir: './src/generated', modulePath: ['Generated', 'Gql', 'Admin'], useNewtypesForRecords: false, - url: 'http://localhost:4000/graphql' + url: 'http://localhost:4892/graphql' }) diff --git a/examples/2-codegen/generate-purs-schema.mjs b/examples/2-codegen/generate-purs-schema.mjs index bcfeb87f..3f53fdd6 100644 --- a/examples/2-codegen/generate-purs-schema.mjs +++ b/examples/2-codegen/generate-purs-schema.mjs @@ -7,5 +7,5 @@ export default () => dir: './src/generated', modulePath: ['Generated', 'Gql', 'Admin'], useNewtypesForRecords: false, - url: 'http://localhost:4000/graphql' + url: 'http://localhost:4892/graphql' }) diff --git a/examples/2-codegen/server-fn.js b/examples/2-codegen/server-fn.js index 23ea6c16..ea6b36a0 100644 --- a/examples/2-codegen/server-fn.js +++ b/examples/2-codegen/server-fn.js @@ -9,8 +9,8 @@ module.exports = (onListening) => { prop: String widgets(id: ID): [Widget!]! } - - type Widget { + + type Widget { id: ID int: Int name: String! @@ -39,5 +39,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/2-codegen/server.js b/examples/2-codegen/server.js index b8065c5b..333a4759 100644 --- a/examples/2-codegen/server.js +++ b/examples/2-codegen/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/2-codegen/src/Main.purs b/examples/2-codegen/src/Main.purs index fcd1c572..4a977d2d 100644 --- a/examples/2-codegen/src/Main.purs +++ b/examples/2-codegen/src/Main.purs @@ -30,4 +30,4 @@ queryGql :: GqlQuery Nil' OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/3-enums/generate-purs-schema.mjs b/examples/3-enums/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/3-enums/generate-purs-schema.mjs +++ b/examples/3-enums/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/3-enums/server-fn.js b/examples/3-enums/server-fn.js index d471e74c..5e8882da 100644 --- a/examples/3-enums/server-fn.js +++ b/examples/3-enums/server-fn.js @@ -47,5 +47,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/3-enums/server.js b/examples/3-enums/server.js index b8065c5b..333a4759 100644 --- a/examples/3-enums/server.js +++ b/examples/3-enums/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/3-enums/src/Main.purs b/examples/3-enums/src/Main.purs index 8fcd64ea..434be48d 100644 --- a/examples/3-enums/src/Main.purs +++ b/examples/3-enums/src/Main.purs @@ -22,7 +22,7 @@ main = { widgets } <- queryGql "WidgetColoursWithId1" { widgets: { colour: RED } =>> { colour } } - + -- Will log [ RED ] as there is one red widget logShow $ map _.colour widgets @@ -32,4 +32,4 @@ queryGql :: GqlQuery Nil' OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/4-mutation/generate-purs-schema.mjs b/examples/4-mutation/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/4-mutation/generate-purs-schema.mjs +++ b/examples/4-mutation/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/4-mutation/server-fn.js b/examples/4-mutation/server-fn.js index c212b090..62dd7b35 100644 --- a/examples/4-mutation/server-fn.js +++ b/examples/4-mutation/server-fn.js @@ -4,7 +4,7 @@ const widgets = [ { id: 2, name: 'two', colour: 'GREEN' } ] -module.exports = (onListening) => { +module.exports = (onListening) => { const express = require('express') const { graphqlHTTP } = require('express-graphql') const { buildSchema } = require('graphql') @@ -28,7 +28,7 @@ module.exports = (onListening) => { yellow } - type Mutation { + type Mutation { set_widget_colour(id: Int!, colour: Colour!): Int! } @@ -58,5 +58,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/4-mutation/server.js b/examples/4-mutation/server.js index b8065c5b..333a4759 100644 --- a/examples/4-mutation/server.js +++ b/examples/4-mutation/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/4-mutation/src/Main.purs b/examples/4-mutation/src/Main.purs index 75c53ea3..a8bdd822 100644 --- a/examples/4-mutation/src/Main.purs +++ b/examples/4-mutation/src/Main.purs @@ -20,7 +20,7 @@ main :: Effect Unit main = do client :: Client _ Schema <- createClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , authToken: Nothing , headers: [] } @@ -59,4 +59,3 @@ main = do -- Will also log [ GREEN ] logShow $ map _.colour updatedWidgetsWithoutCache - diff --git a/examples/5-subscription/generate-purs-schema.mjs b/examples/5-subscription/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/5-subscription/generate-purs-schema.mjs +++ b/examples/5-subscription/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/5-subscription/server-fn.js b/examples/5-subscription/server-fn.js index 43c1909b..02afa6a3 100644 --- a/examples/5-subscription/server-fn.js +++ b/examples/5-subscription/server-fn.js @@ -28,7 +28,7 @@ module.exports = async (onListening) => { comment: String! } `) - const PORT = 4000 + const PORT = 4892 const app = express() app.use('/graphql', bodyParser.json()) @@ -75,7 +75,7 @@ module.exports = async (onListening) => { plugins: [ // Proper shutdown for the HTTP server. ApolloServerPluginDrainHttpServer({ httpServer }), - + // Proper shutdown for the WebSocket server. { async serverWillStart() { diff --git a/examples/5-subscription/src/Main.purs b/examples/5-subscription/src/Main.purs index 2a8510df..078417b8 100644 --- a/examples/5-subscription/src/Main.purs +++ b/examples/5-subscription/src/Main.purs @@ -18,10 +18,10 @@ main :: Effect Unit main = do client :: Client _ Schema <- createSubscriptionClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , authToken: Nothing , headers: [] - , websocketUrl: "ws://localhost:4000/graphql" + , websocketUrl: "ws://localhost:4892/graphql" } let event = subscription client "get_props" { postAdded: { author: unit, comment: unit } } diff --git a/examples/6-watch-query/generate-purs-schema.mjs b/examples/6-watch-query/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/6-watch-query/generate-purs-schema.mjs +++ b/examples/6-watch-query/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/6-watch-query/server-fn.js b/examples/6-watch-query/server-fn.js index 43c1909b..02afa6a3 100644 --- a/examples/6-watch-query/server-fn.js +++ b/examples/6-watch-query/server-fn.js @@ -28,7 +28,7 @@ module.exports = async (onListening) => { comment: String! } `) - const PORT = 4000 + const PORT = 4892 const app = express() app.use('/graphql', bodyParser.json()) @@ -75,7 +75,7 @@ module.exports = async (onListening) => { plugins: [ // Proper shutdown for the HTTP server. ApolloServerPluginDrainHttpServer({ httpServer }), - + // Proper shutdown for the WebSocket server. { async serverWillStart() { diff --git a/examples/6-watch-query/src/Main.purs b/examples/6-watch-query/src/Main.purs index d2c3a1fa..5d045f4d 100644 --- a/examples/6-watch-query/src/Main.purs +++ b/examples/6-watch-query/src/Main.purs @@ -19,10 +19,10 @@ main :: Effect Unit main = do client :: Client _ Schema <- createSubscriptionClient - { url: "http://localhost:4000/graphql" + { url: "http://localhost:4892/graphql" , authToken: Nothing , headers: [] - , websocketUrl: "ws://localhost:4000/subscriptions" + , websocketUrl: "ws://localhost:4892/subscriptions" } let myQuery = { posts: { author: unit, comment: unit } } @@ -33,9 +33,9 @@ main = do log "Event recieved" logShow e - let - addComment author comment = - let + let + addComment author comment = + let update = updateCacheJson client myQuery \{ posts } -> {posts: posts <> [{author, comment}]} in @@ -47,4 +47,3 @@ main = do launchAff_ do delay $ Milliseconds 25.0 addComment "joe bloggs" "good" - diff --git a/examples/7-field-type-overrides/generate-purs-schema.mjs b/examples/7-field-type-overrides/generate-purs-schema.mjs index f24c726a..41dbe045 100644 --- a/examples/7-field-type-overrides/generate-purs-schema.mjs +++ b/examples/7-field-type-overrides/generate-purs-schema.mjs @@ -7,7 +7,7 @@ export default () => dir: "./src/generated", modulePath: ["Generated", "Gql", "Admin"], useNewtypesForRecords: false, - url: "http://localhost:4000/graphql", + url: "http://localhost:4892/graphql", fieldTypeOverrides: { Widget: { special_string: { moduleName: "DataTypes", typeName: "MyNewtype" }, diff --git a/examples/7-field-type-overrides/server-fn.js b/examples/7-field-type-overrides/server-fn.js index 4b846284..75b53d92 100644 --- a/examples/7-field-type-overrides/server-fn.js +++ b/examples/7-field-type-overrides/server-fn.js @@ -8,8 +8,8 @@ module.exports = (onListening) => { type Query { widgets(id: ID): [Widget!]! } - - type Widget { + + type Widget { id: ID special_string: String! } @@ -33,5 +33,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/7-field-type-overrides/server.js b/examples/7-field-type-overrides/server.js index b8065c5b..333a4759 100644 --- a/examples/7-field-type-overrides/server.js +++ b/examples/7-field-type-overrides/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/7-field-type-overrides/src/Main.purs b/examples/7-field-type-overrides/src/Main.purs index bc51ede1..8def8d8a 100644 --- a/examples/7-field-type-overrides/src/Main.purs +++ b/examples/7-field-type-overrides/src/Main.purs @@ -27,4 +27,4 @@ queryGql :: GqlQuery Nil' OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/8-custom-gql-types/generate-purs-schema.mjs b/examples/8-custom-gql-types/generate-purs-schema.mjs index aacddf11..22ae6371 100644 --- a/examples/8-custom-gql-types/generate-purs-schema.mjs +++ b/examples/8-custom-gql-types/generate-purs-schema.mjs @@ -7,7 +7,7 @@ export default () => dir: "./src/generated", modulePath: ["Generated", "Gql", "Admin"], useNewtypesForRecords: false, - url: "http://localhost:4000/graphql", + url: "http://localhost:4892/graphql", gqlToPursTypes: { GqlTypeThatIsAString: { typeName: "String", moduleName: "" }, GqlTypeThatIsAnInt: { typeName: "Int", moduleName: "" }, diff --git a/examples/8-custom-gql-types/server-fn.js b/examples/8-custom-gql-types/server-fn.js index 18f84d36..f9dec3e6 100644 --- a/examples/8-custom-gql-types/server-fn.js +++ b/examples/8-custom-gql-types/server-fn.js @@ -9,8 +9,8 @@ module.exports = (onListening) => { prop: GqlTypeThatIsAString widgets(id: ID): [Widget!]! } - - type Widget { + + type Widget { id: ID int: GqlTypeThatIsAnInt name: GqlTypeThatIsAString! @@ -42,5 +42,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/8-custom-gql-types/server.js b/examples/8-custom-gql-types/server.js index b8065c5b..333a4759 100644 --- a/examples/8-custom-gql-types/server.js +++ b/examples/8-custom-gql-types/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/8-custom-gql-types/src/Main.purs b/examples/8-custom-gql-types/src/Main.purs index fcd1c572..4a977d2d 100644 --- a/examples/8-custom-gql-types/src/Main.purs +++ b/examples/8-custom-gql-types/src/Main.purs @@ -30,4 +30,4 @@ queryGql :: GqlQuery Nil' OpQuery Query query returns => DecodeJson returns => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/examples/9-variables/generate-purs-schema.mjs b/examples/9-variables/generate-purs-schema.mjs index ed9aa2aa..3c755b93 100644 --- a/examples/9-variables/generate-purs-schema.mjs +++ b/examples/9-variables/generate-purs-schema.mjs @@ -9,7 +9,7 @@ export default () => useNewtypesForRecords: false }, [ { - url: 'http://localhost:4000/graphql', + url: 'http://localhost:4892/graphql', moduleName: 'Admin' } ]) diff --git a/examples/9-variables/server-fn.js b/examples/9-variables/server-fn.js index 3fa97518..bfbd7e11 100644 --- a/examples/9-variables/server-fn.js +++ b/examples/9-variables/server-fn.js @@ -50,5 +50,5 @@ module.exports = (onListening) => { graphiql: true })) - app.listen(4000, onListening) + app.listen(4892, onListening) } diff --git a/examples/9-variables/server.js b/examples/9-variables/server.js index b8065c5b..333a4759 100644 --- a/examples/9-variables/server.js +++ b/examples/9-variables/server.js @@ -1,4 +1,4 @@ import serverFn from './server-fn.js' serverFn(() => { - console.info('Running a GraphQL API server at http://localhost:4000/graphql') + console.info('Running a GraphQL API server at http://localhost:4892/graphql') }) diff --git a/examples/9-variables/src/Main.purs b/examples/9-variables/src/Main.purs index e1c309e4..4b728dcd 100644 --- a/examples/9-variables/src/Main.purs +++ b/examples/9-variables/src/Main.purs @@ -54,4 +54,4 @@ queryGql => String -> query -> Aff returns -queryGql = query_ "http://localhost:4000/graphql" (Proxy :: Proxy Query) +queryGql = query_ "http://localhost:4892/graphql" (Proxy :: Proxy Query) diff --git a/spago.dhall b/spago.dhall index 17c2d2ec..3384ef80 100644 --- a/spago.dhall +++ b/spago.dhall @@ -29,6 +29,7 @@ You can edit this file as you like. , "halogen-subscriptions" , "heterogeneous" , "http-methods" + , "identity" , "integers" , "lists" , "maybe" diff --git a/src/GraphQL/Client/ArrayOf.purs b/src/GraphQL/Client/ArrayOf.purs new file mode 100644 index 00000000..c8193083 --- /dev/null +++ b/src/GraphQL/Client/ArrayOf.purs @@ -0,0 +1,18 @@ +module GraphQL.Client.ArrayOf + ( ArrayOf (..) + , arrayOf + ) where + +import Data.Newtype (class Newtype) + + +-- | An array type for more control over type inference. +-- +-- This is useful for distinguising between `f (Array a)`` and `Array (f a)` in the return type, +-- where `f` is `Identity` or `ErrorBoundary`. +newtype ArrayOf a = ArrayOf a + +derive instance newtypeArrayOf :: Newtype (ArrayOf a) _ + +arrayOf :: forall q . q -> ArrayOf q +arrayOf = ArrayOf diff --git a/src/GraphQL/Client/QueryReturns.purs b/src/GraphQL/Client/QueryReturns.purs index e5037b88..4625544f 100644 --- a/src/GraphQL/Client/QueryReturns.purs +++ b/src/GraphQL/Client/QueryReturns.purs @@ -8,12 +8,14 @@ module GraphQL.Client.QueryReturns import Prelude +import Data.Identity (Identity(..)) import Data.Maybe (Maybe) import Data.Newtype (class Newtype, unwrap) import Data.Symbol (class IsSymbol) import GraphQL.Client.Alias (Alias(..)) import GraphQL.Client.Alias.Dynamic (Spread, SpreadRes) import GraphQL.Client.Args (class SatisifyNotNullParam, ArgPropToGql, Args(..)) +import GraphQL.Client.ArrayOf (ArrayOf(..)) import GraphQL.Client.AsGql (AsGql) import GraphQL.Client.Directive (ApplyDirective) import GraphQL.Client.ErrorBoundary (BoundaryResult, ErrorBoundary) @@ -55,6 +57,8 @@ else instance queryReturnsGqlType :: QueryReturnsAt at a q t => QueryReturnsAt a queryReturnsAtImpl at _ q = queryReturnsAtImpl at (undefined :: a) q else instance queryReturnsApplyDirective :: QueryReturnsAt at a q t => QueryReturnsAt at a (ApplyDirective name args q) t where queryReturnsAtImpl at a _ = queryReturnsAtImpl at a (undefined :: q) +else instance queryReturnsIdentity :: QueryReturnsAt at a q t => QueryReturnsAt at a (Identity q) (Identity t) where + queryReturnsAtImpl at a _ = Identity $ queryReturnsAtImpl at a (undefined :: q) else instance queryReturnErrorBoundary :: QueryReturnsAt at a q t => QueryReturnsAt at a (ErrorBoundary q) (BoundaryResult Unit t) where queryReturnsAtImpl at a _ = ErrorBoundary.Result $ queryReturnsAtImpl at a (undefined :: q) else instance queryReturnsSpread :: @@ -70,14 +74,16 @@ else instance queryReturnsSpreadNewtype :: ) => QueryReturnsAt at newtypeSchema (Spread (Proxy alias) args q) (SpreadRes returns) where queryReturnsAtImpl at _ _ = undefined +else instance queryReturnsArrayOf :: QueryReturnsAt at a q t => QueryReturnsAt at (Array a) (ArrayOf q) (Array t) where + queryReturnsAtImpl at _ (ArrayOf q) = pure $ queryReturnsAtImpl at (undefined :: a) q else instance queryReturnsArray :: QueryReturnsAt at a q t => QueryReturnsAt at (Array a) q (Array t) where queryReturnsAtImpl at _ q = pure $ queryReturnsAtImpl at (undefined :: a) q else instance queryReturnsMaybe :: QueryReturnsAt at a q t => QueryReturnsAt at (Maybe a) q (Maybe t) where queryReturnsAtImpl at _ q = pure $ queryReturnsAtImpl at (undefined :: a) q else instance queryReturnsUnion :: - HMapWithIndex (PropToSchemaType schema) (Record query) (Record returns) => + HMapWithIndex (PropToSchemaType schema) { | query} { | returns } => QueryReturnsAt at (GqlUnion schema) (GqlUnion query) (UnionReturned returns) where - queryReturnsAtImpl at _ _ = undefined + queryReturnsAtImpl _ _ _ = undefined else instance queryReturnsParamsArgs :: ( QueryReturnsAt at t q result , HMapWithIndex (ArgPropToGql params) { | args } s diff --git a/src/GraphQL/Client/ToGqlString.purs b/src/GraphQL/Client/ToGqlString.purs index f9335d49..14319888 100644 --- a/src/GraphQL/Client/ToGqlString.purs +++ b/src/GraphQL/Client/ToGqlString.purs @@ -41,6 +41,7 @@ import Data.DateTime as DT import Data.Enum (class BoundedEnum, fromEnum) import Data.FoldableWithIndex (foldlWithIndex) import Data.Function (on) +import Data.Identity (Identity(..)) import Data.List (List) import Data.List as List import Data.Map (Map) @@ -62,6 +63,7 @@ import GraphQL.Client.Alias (Alias(..)) import GraphQL.Client.Alias.Dynamic (Spread(..)) import GraphQL.Client.Args (AndArgs(AndArgs), Args(..), IgnoreArg, OrArg(..)) import GraphQL.Client.Args.AllowedMismatch (AllowedMismatch) +import GraphQL.Client.ArrayOf (ArrayOf(..)) import GraphQL.Client.Directive (ApplyDirective(..)) import GraphQL.Client.ErrorBoundary (ErrorBoundary(..)) import GraphQL.Client.NullArray (NullArray) @@ -108,8 +110,12 @@ else instance gqlQueryStringApplyDirective :: <> reflectSymbol (Proxy :: Proxy name) <> gqlArgStringRecordTopLevel args <> toGqlQueryStringImpl opts q +else instance gqlQueryStringIdentity :: GqlQueryString a => GqlQueryString (Identity a) where + toGqlQueryStringImpl opts (Identity a) = toGqlQueryStringImpl opts a else instance gqlQueryStringErrorBoundary :: GqlQueryString a => GqlQueryString (ErrorBoundary a) where toGqlQueryStringImpl opts (ErrorBoundary a) = toGqlQueryStringImpl opts a +else instance gqlQueryStringArrayOf :: GqlQueryString a => GqlQueryString (ArrayOf a) where + toGqlQueryStringImpl opts (ArrayOf a) = toGqlQueryStringImpl opts a else instance gqlQueryStringSymbol :: IsSymbol s => GqlQueryString (Proxy s) where toGqlQueryStringImpl _ _ = ": " <> reflectSymbol (Proxy :: Proxy s) else instance gqlQueryStringVar :: IsSymbol s => GqlQueryString (Var s a) where @@ -484,4 +490,3 @@ else instance isIgnoreArgOrArg :: (IsIgnoreArg l, IsIgnoreArg r) => IsIgnoreArg ArgR r -> isIgnoreArg r else instance isIgnoreArgOther :: IsIgnoreArg a where isIgnoreArg _ = false - diff --git a/src/GraphQL/Client/Union.purs b/src/GraphQL/Client/Union.purs index 594f83e9..f5b7356b 100644 --- a/src/GraphQL/Client/Union.purs +++ b/src/GraphQL/Client/Union.purs @@ -18,11 +18,15 @@ import Type.Proxy (Proxy(..)) newtype GqlUnion r = GqlUnion (Record r) -derive instance newtypeGqlUnion :: Newtype (GqlUnion r) _ +derive newtype instance Eq (Record r) => Eq (GqlUnion r) +derive newtype instance Ord (Record r) => Ord (GqlUnion r) +derive instance Newtype (GqlUnion r) _ newtype UnionReturned r = UnionReturned (Variant r) -derive instance newtypeGqlUnionReturned :: Newtype (UnionReturned r) _ +derive newtype instance Eq (Variant r) => Eq (UnionReturned r) +derive newtype instance Ord (Variant r) => Ord (UnionReturned r) +derive instance Newtype (UnionReturned r) _ instance (RL.RowToList r rl, DecodeUnion rl r) => DecodeJson (UnionReturned r) where decodeJson = decodeJsonUnionWith (decodeUnion :: _ -> _ -> Proxy rl -> _) @@ -104,4 +108,3 @@ failedAtTypename ty _ _ = Left $ AtKey __typename $ UnexpectedValue $ fromString __typename :: String __typename = "__typename" - diff --git a/src/GraphQL/Client/Variables.purs b/src/GraphQL/Client/Variables.purs index 3a8219da..eb15945f 100644 --- a/src/GraphQL/Client/Variables.purs +++ b/src/GraphQL/Client/Variables.purs @@ -27,6 +27,7 @@ import Prelude import Control.Apply (lift2) import Data.Argonaut.Core (Json, jsonEmptyObject) import Data.Argonaut.Encode (class EncodeJson, encodeJson) +import Data.Identity (Identity) import Data.List (List(..), intercalate) import Data.Maybe (Maybe(..)) import Data.Newtype (class Newtype, unwrap) @@ -142,6 +143,12 @@ else instance getVarOrArg :: varR = getVar (Proxy :: _ r) in lift2 Record.merge varL varR +-- else instance getVarUnion :: +-- ( HFoldl GetVarRec (Proxy {}) { | query } (Proxy { | var }) +-- ) => +-- GetVar (GqlUnion query) { | var } where +-- getVar _ = Proxy -- q >>= \query -> hfoldl GetVarRec (Proxy :: _ {}) (query :: { | query }) + else instance getVarRecord :: ( HFoldl GetVarRec (Proxy {}) { | query } (Proxy { | var }) ) => @@ -220,6 +227,24 @@ else instance varsTypeCheckedWithoutVars :: getVarsJson _ _ = jsonEmptyObject getVarsTypeNames _ _ = "" +else instance varsTypeCheckedIdentity :: + GetVar query {} => + VarsTypeChecked schema (Identity query) where + getVarsJson _ _ = jsonEmptyObject + getVarsTypeNames _ _ = "" + +else instance varsTypeCheckedErrorBoundary :: + GetVar query {} => + VarsTypeChecked schema (ErrorBoundary query) where + getVarsJson _ _ = jsonEmptyObject + getVarsTypeNames _ _ = "" + +else instance varsTypeCheckedUnion :: + GetVar { | query } {} => + VarsTypeChecked schema (GqlUnion query) where + getVarsJson _ _ = jsonEmptyObject + getVarsTypeNames _ _ = "" + else instance varsTypeCheckedSpread :: GetVar (Spread alias arg fields) {} => VarsTypeChecked schema (Spread alias arg fields) where @@ -398,4 +423,3 @@ endsWith c str = removeSuffix :: Char -> String -> String removeSuffix c str = if endsWith c str then String.take (String.length str - 1) str else str - diff --git a/test/GraphQL/Client/QueryReturns.Test.purs b/test/GraphQL/Client/QueryReturns.Test.purs index d0787079..2c2b8fed 100644 --- a/test/GraphQL/Client/QueryReturns.Test.purs +++ b/test/GraphQL/Client/QueryReturns.Test.purs @@ -2,11 +2,13 @@ module GraphQL.Client.QueryReturns.Test where import Prelude +import Data.Identity (Identity(..)) import Data.Maybe (Maybe(..)) import Data.Newtype (class Newtype) import GraphQL.Client.Alias ((:)) import GraphQL.Client.Alias.Dynamic (Spread(..), SpreadRes) import GraphQL.Client.Args (IgnoreArg(..), NotNull, OrArg(..), (++), (+++), (=>>)) +import GraphQL.Client.ArrayOf (arrayOf) import GraphQL.Client.Directive (applyDir) import GraphQL.Client.NullArray (NullArray(..)) import GraphQL.Client.QueryReturns (class QueryReturns, queryReturns) @@ -328,6 +330,74 @@ testDirective = =>> { id } } +testIdentity + :: Proxy + { users :: + Array + { id :: Identity Int + } + } +testIdentity = + queryReturns testSchemaProxy + { users: + { is_in_rec: + [ { int: 0 } ] +++ ((ArgR [ ignoreOrStr true, ignoreOrStr false ]) :: OrArg IgnoreArg _) + } + =>> { id: Identity id } + } + +testArrayOf + :: Proxy + { users :: + Array + { id :: Int + } + } +testArrayOf = + queryReturns testSchemaProxy + { users: + { is_in_rec: + [ { int: 0 } ] +++ ((ArgR [ ignoreOrStr true, ignoreOrStr false ]) :: OrArg IgnoreArg _) + } + =>> { id: arrayOf id } + } + +testArrayOfIdentities + :: Proxy + { users :: + Array + ( Identity + { id :: Int + } + ) + } +testArrayOfIdentities = + queryReturns testSchemaProxy + { users: + { is_in_rec: + [ { int: 0 } ] +++ ((ArgR [ ignoreOrStr true, ignoreOrStr false ]) :: OrArg IgnoreArg _) + } + =>> arrayOf (Identity { id }) + } + +testIdentityOfArray + :: Proxy + { users :: + Identity + ( Array + { id :: Int + } + ) + } +testIdentityOfArray = + queryReturns testSchemaProxy + { users: + { is_in_rec: + [ { int: 0 } ] +++ ((ArgR [ ignoreOrStr true, ignoreOrStr false ]) :: OrArg IgnoreArg _) + } + =>> Identity { id } + } + ignoreOrStr :: Boolean -> OrArg IgnoreArg diff --git a/test/GraphQL/Client/ToGqlString.Test.purs b/test/GraphQL/Client/ToGqlString.Test.purs index 5524b787..64dd8ee3 100644 --- a/test/GraphQL/Client/ToGqlString.Test.purs +++ b/test/GraphQL/Client/ToGqlString.Test.purs @@ -5,6 +5,7 @@ import Prelude import GraphQL.Client.Alias ((:)) import GraphQL.Client.Alias.Dynamic (Spread(..)) import GraphQL.Client.Args (IgnoreArg(..), OrArg(..), (++), (+++), (=>>)) +import GraphQL.Client.ArrayOf (arrayOf) import GraphQL.Client.Directive (applyDir) import GraphQL.Client.ToGqlString (gqlArgStringRecordTopLevel, toGqlQueryString, toGqlQueryStringFormatted) import GraphQL.Client.Variable (Var(..)) @@ -260,4 +261,14 @@ spec = `shouldEqual` """@cached { a +}""" + it "ignores arrayOf" $ + toGqlQueryStringFormatted + { foo: { bar: arrayOf unit } + } + `shouldEqual` + """ { + foo { + bar + } }"""