fix: Only include the bulk update arguments on the plur… (#54)

* introspection fix: Only include the bulk update arguments on the plural versions of the fields.

* Fixes error graphql: Unknown type "String!"
This commit is contained in:
Hiram Chirino 2020-04-21 10:41:28 -04:00 committed by GitHub
parent 2a32c179ba
commit 7a3fe5a1df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 28 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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 {