diff --git a/core/graph-schema.go b/core/graph-schema.go index f6261de..3d477b9 100644 --- a/core/graph-schema.go +++ b/core/graph-schema.go @@ -268,7 +268,7 @@ enum OrderDirection { args = append(args, &schema.InputValue{ Desc: &schema.Description{Text: "Performs full text search using a TSV index"}, Name: schema.Ident{Text: "search"}, - Type: &schema.TypeName{Ident: schema.Ident{Text: "String!"}}, + Type: &schema.NonNull{OfType: &schema.TypeName{Ident: schema.Ident{Text: "String"}}}, }) } @@ -285,49 +285,51 @@ enum OrderDirection { Args: args, }) - mutationArgs := schema.InputValueList{ + mutationArgs := append(args, schema.InputValueList{ &schema.InputValue{ Desc: &schema.Description{Text: ""}, Name: schema.Ident{Text: "insert"}, Type: inputTypeName, }, - &schema.InputValue{ - Desc: &schema.Description{Text: ""}, - Name: schema.Ident{Text: "inserts"}, - Type: pluralInputTypeName, - }, &schema.InputValue{ Desc: &schema.Description{Text: ""}, Name: schema.Ident{Text: "update"}, Type: inputTypeName, }, - &schema.InputValue{ - Desc: &schema.Description{Text: ""}, - Name: schema.Ident{Text: "updates"}, - Type: pluralInputTypeName, - }, + &schema.InputValue{ Desc: &schema.Description{Text: ""}, Name: schema.Ident{Text: "upsert"}, Type: inputTypeName, }, - &schema.InputValue{ - Desc: &schema.Description{Text: ""}, - Name: schema.Ident{Text: "upserts"}, - Type: pluralInputTypeName, - }, - } + }...) + mutation.Fields = append(mutation.Fields, &schema.Field{ Name: singularName, - Args: append(args, mutationArgs...), + Args: mutationArgs, Type: outputType, }) mutation.Fields = append(mutation.Fields, &schema.Field{ Name: pluralName, - Args: append(args, mutationArgs...), + Args: append(mutationArgs, schema.InputValueList{ + &schema.InputValue{ + Desc: &schema.Description{Text: ""}, + Name: schema.Ident{Text: "inserts"}, + Type: pluralInputTypeName, + }, + &schema.InputValue{ + Desc: &schema.Description{Text: ""}, + Name: schema.Ident{Text: "updates"}, + Type: pluralInputTypeName, + }, + &schema.InputValue{ + Desc: &schema.Description{Text: ""}, + Name: schema.Ident{Text: "upserts"}, + Type: pluralInputTypeName, + }, + }...), Type: outputType, }) - } for typeName, _ := range scalarExpressionTypesNeeded { diff --git a/core/internal/integration_tests/integration_tests.go b/core/internal/integration_tests/integration_tests.go index f175e19..a3659e4 100644 --- a/core/internal/integration_tests/integration_tests.go +++ b/core/internal/integration_tests/integration_tests.go @@ -156,7 +156,7 @@ func TestSuperGraph(t *testing.T, db *sql.DB, before func(t *testing.T)) { schema, err := sg.GraphQLSchema() require.NoError(t, err) // Uncomment the following line if you need to regenerate the expected schema. - // ioutil.WriteFile("../introspection.graphql", []byte(schema), 0644) + //ioutil.WriteFile("../introspection.graphql", []byte(schema), 0644) expected, err := ioutil.ReadFile("../introspection.graphql") require.NoError(t, err) assert.Equal(t, string(expected), schema) diff --git a/core/internal/integration_tests/introspection.graphql b/core/internal/integration_tests/introspection.graphql index 313deeb..40dc17a 100644 --- a/core/internal/integration_tests/introspection.graphql +++ b/core/internal/integration_tests/introspection.graphql @@ -67,37 +67,37 @@ type Mutation { "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:line_itemOrderBy!, where:line_itemExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:line_itemInput, inserts:[line_itemInput!]!, update:line_itemInput, updates:[line_itemInput!]!, upsert:line_itemInput, upserts:[line_itemInput!]! + id:Int!, insert:line_itemInput, update:line_itemInput, upsert:line_itemInput ):line_itemOutput line_items( "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:line_itemOrderBy!, where:line_itemExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:line_itemInput, inserts:[line_itemInput!]!, update:line_itemInput, updates:[line_itemInput!]!, upsert:line_itemInput, upserts:[line_itemInput!]! + id:Int!, insert:line_itemInput, update:line_itemInput, upsert:line_itemInput, inserts:[line_itemInput!]!, updates:[line_itemInput!]!, upserts:[line_itemInput!]! ):line_itemOutput product( "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:productOrderBy!, where:productExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:productInput, inserts:[productInput!]!, update:productInput, updates:[productInput!]!, upsert:productInput, upserts:[productInput!]! + id:Int!, insert:productInput, update:productInput, upsert:productInput ):productOutput products( "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:productOrderBy!, where:productExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:productInput, inserts:[productInput!]!, update:productInput, updates:[productInput!]!, upsert:productInput, upserts:[productInput!]! + id:Int!, insert:productInput, update:productInput, upsert:productInput, inserts:[productInput!]!, updates:[productInput!]!, upserts:[productInput!]! ):productOutput user( "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:userOrderBy!, where:userExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:userInput, inserts:[userInput!]!, update:userInput, updates:[userInput!]!, upsert:userInput, upserts:[userInput!]! + id:Int!, insert:userInput, update:userInput, upsert:userInput ):userOutput users( "To sort or ordering results just use the order_by argument. This can be combined with where, search, etc to build complex queries to fit you needs." order_by:userOrderBy!, where:userExpression!, limit:Int!, offset:Int!, first:Int!, last:Int!, before:String, after:String, "Finds the record by the primary key" - id:Int!, insert:userInput, inserts:[userInput!]!, update:userInput, updates:[userInput!]!, upsert:userInput, upserts:[userInput!]! + id:Int!, insert:userInput, update:userInput, upsert:userInput, inserts:[userInput!]!, updates:[userInput!]!, upserts:[userInput!]! ):userOutput } enum OrderDirection {